lundi 28 décembre 2015

One url/route two different controller laravel 5 based on user logged in or not

How can I load different controllers based on user logged in or not ?

What I'm trying to do is

// in app/Http/routes.php

Route::get('/', [
    'uses' => 'App\Http\Controllers\HomeController@index',
]);


// modules/Lesson/Http/routes.ph

Route::group(['middleware' => 'auth'], function () {

    Route::get('/', [
        'uses' => 'Modules\Lesson\Http\Controllers\DashboardController@index',
    ]);
});

So when user logged in, it shows DashboardController@index, otherwise HomeController@index

But it always loading /login form when user not signed in.

Is there any way to achieve this?

I have seen following link Laravel 5 Entrust one route - load different controller based on Role. But i can't do like that since module is optional



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire