Tetravalence

Experience

1,940

0 Best Reply Awards

  • Member Since 5 Months Ago
  • 13 Lessons Completed
  • 0 Favorites

14th August, 2018

Tetravalence started a new conversation ErrorException Using Readlink() • 6 days ago

Hello, I have an ErrorException that I'd like to handle when readlink() returns false.

public static function validateLink()
{
        $public_resources = public_path().
            '/vendor/'.static::getVendor().'/assets';

        return readlink($public_resources) ?
            $public_resources : false;
}

The failure is an expected behavior so I need the script continues to run after ternary operator.

12th August, 2018

Tetravalence left a reply on How To Use Auth Middleware In My Own Package • 1 week ago

@iambaz You did resolve my problem. Thank you.

Does anyone know why this code below is not working?

Route::middleware('web', 'auth', 'dashboard')->group(function () {
    Route::get('/dashboard', '[email protected]');
    Route::get('/dashboard/template', '[email protected]')->name('template');
});

While this one is correct

Route::group(['middleware' => ['web', 'auth', 'dashboard']], function () {
  Route::get('/dashboard', '[email protected]');
  Route::get('/dashboard/template', '[email protected]')->name('template');
});

Tetravalence left a reply on Problem With Auth Middleware • 1 week ago

@crnkovic the Auth middleware does a redirect back to the /home whenever I try to access the /got route even though I'm logged in. The code works fine if added to the main application route routes/web.php but it does not work if added to the package route vendor/tetravalence/mypackage/routes/web.php.

Tetravalence started a new conversation Problem With Auth Middleware • 1 week ago

Hi! The following snippet of code taken from a tutorial by Auth0.com

Route::get('/got', [
  'middleware' => ['auth'],
  'uses' => function () {
   echo "You are allowed to view this page!";
}]);

What is that supposed to do? When I log out and I try to access that route, Auth middleware redirected back to the/login route, same thing happens when I log in, the echo message is not displayed. Why?

11th August, 2018

Tetravalence left a reply on Assign A Key To Middleware In Package Development • 1 week ago

@tykus OK. Thank you!

10th August, 2018

Tetravalence started a new conversation Assign A Key To Middleware In Package Development • 1 week ago

Hello, I'd like to share Middlewares across a group of routes without needing to use their FQN. I know it's possible to assign the Middleware a key in app/Http/Kernel.php but I'm looking for a solution in package development that does not require to change the aforementioned file. Right now I'm using the MyPackageDashboard Middleware by means of his FQN

Route::middleware('auth', Tetravalence\MyPackage\Http\Middleware\MyPackageDashboard::class)->group(function () {
...
// group of routes
}

Where can I set up these keys in package development?

8th August, 2018

Tetravalence left a reply on Implement Mutiple Themes In A Laravel CMS • 1 week ago

@Aleem raised the problem I'm facing with package development. Does anyone know if I have to use a Middleware class to filter any asset used in the active theme? For exemple if current theme does use assets from this directory

/vendor/tetravalence/package/template/current/public/assets/css/style.css

the Middleware should copy style.css into public but I'm not sure if this task can be accomplished in an efficient way. I would be grateful for any advice you can give me.

6th August, 2018

Tetravalence left a reply on Subtitles Or Scripts For Lectures... • 2 weeks ago

@bobbybouwmann Edx videos go through automatic speech recognition to produce caption and transcript. They use external service from Cielo24 or 3 Play Media.

29th July, 2018

Tetravalence left a reply on Subtitles For Tutorials • 3 weeks ago

Any update? I have some difficulty with English listening. Thanks in advance

Tetravalence left a reply on Best Way To Set-up A Package Via Web? • 3 weeks ago

OK this question has been satisfactorily solved using a Service Provider and a global Middleware.

28th July, 2018

Tetravalence left a reply on Best Way To Set-up A Package Via Web? • 3 weeks ago

@cmdobueno OK, I find your idea really interesting but how should I implement it? Here is my test procedure which is not working, however:

  1. In Mypackage Service Provider I use the app array to inject the middleware into the Kernel in the similar way as it is done in Debug Bar service provider using pushMiddleware method.
  2. The middleware extends CheckForMaintenanceMode class.
  3. The Web route file has the following entry
Route::get('/maintenance', '[email protected]`);

Unfortunatly, the application continues to load the 503 default view bypassing my middleware.

26th July, 2018

Tetravalence started a new conversation Best Way To Set-up A Package Via Web? • 3 weeks ago

Hi, my package needs some records in the tables to work, for example the name of default theme, the e-mail of the site owner, etc. What's the best approach to this? I use a conditional statement in the route file together to a Controller that runs some routine, for example in routes/web.php

if (!file_exists(config_path().'/myapp.php')) {
    Route::get('/', '[email protected]');
} else {
   Route::get('/', '[email protected]');
}

So, if myapp.php file does not exist in config directory then MyApp runs the installer. The alternative is to use artisan vendor:publish from command line. Is this the correct way to proceed?

25th July, 2018

Tetravalence left a reply on Eloquent Model's Created_at And Updated_at Do Not Work • 3 weeks ago

@36864 : OK I've got it. Thank you!

Tetravalence left a reply on Eloquent Model's Created_at And Updated_at Do Not Work • 3 weeks ago

@Sergiu17 Eloquoent's documentation shows this "If you would like to generate a database migration when you generate the model, you may use the --migration or -m option:" then I don't understand what the two constants are supposed to do

Tetravalence started a new conversation Eloquent Model's Created_at And Updated_at Do Not Work • 3 weeks ago

Hello, according to Eloquent documentation if I need to customize the names of the columns used to store the timestamps, I may set the CREATED_AT and UPDATED_AT constants in my model, but this does not seem to work in my application.

'''

5th July, 2018

Tetravalence started a new conversation What Is The Difference Between Tag And Provider Option In Vendor:publish Command? • 1 month ago

Could someone please explain me the difference between tag and provider option in vendor:publish command issued with php artisan? Does this snippet of code

$this->publishes([
            dirname(dirname(__FILE__)).
                '/config/mypackage.php' => config_path('mypackage.php'),
        ], 'mypackage');

seems to work exactly like this and why?

$this->publishes([
            dirname(dirname(__FILE__)).
                '/config/mypackage.php' => config_path('mypackage.php'),
        ]);

1st July, 2018

Tetravalence left a reply on Modifying Column Type To BigIncrements Without DBAL Library • 1 month ago

@Thyrosis: quite right too but I might need to install the package on, let's say, about twenty sites. I prefer a procedure performed by the package itself . Unfortunately, as you say, any user data is lost and the customer could get angry.

Tetravalence started a new conversation Modifying Column Type To BigIncrements Without DBAL Library • 1 month ago

Hello, according to Laravel's documentation in order to modify existing column types, the Doctrine DBAL library has to be installed. Furthermore only certain column types can be "changed". I'm working on an blog package and I need the 'id' column to be bigIncrements instead of increments provided as default in the Laravel migration file for the 'users' table. My solution is to use the Schema facade to drop the 'id' column via 'up' method from migration class of the package, then restore the 'id' column with the new type:

 if (Schema::hasColumn('users', 'id')) {
    Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('id');
                //$table->bigIncrements('id');
        });
        Schema::table('users', function (Blueprint $table) {
                $table->bigIncrements('id')->first();
        });
}

Is this the right way to modify an existing migration without DBAL library? I don't understand because I have to create the 'id' column in a separate Schema block whereas if I try to use dropColumn and bigIncrements methods together then Laravel returns a message error.

15th June, 2018

Tetravalence left a reply on How To Grab Error Code When .env File Does Not Exist? • 2 months ago

@Snapey: OK, now if I run the command php artisan config:cache for deploying my application to production I still get the 500 error message from the server when .env file does not exist in the root of the application directory. So I guess I have overlooked some basic information about the deployment procedure. Thanks for all the replies

11th June, 2018

Tetravalence started a new conversation How To Grab Error Code When .env File Does Not Exist? • 2 months ago

Hello, I would like my package to handle the Laravel request when .env file does not exist in the application directory and the web server send the 500 error. Should I use both controller and view for this purpose or I have to register an Exception Handler?

5th April, 2018

Tetravalence left a reply on Defining Middleware • 4 months ago

OK, thank you for replying

Tetravalence started a new conversation Defining Middleware • 4 months ago

Hello! I'm new to Laravel, sorry for this silly question but I don't understand how/where $request object defines the age public property in "Defining Middleware" guide to Laravel 5.6

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.