I have following code:
Route::group(['middleware' => ['auth']], function () {
dd($user);
Route::get('/', 'SiteController@index');
});
The $user is created in the AppServiceProvider, but it is not accessible in the Route:
public function boot()
{
view()->composer('layouts.main', function($view){
$employees = \App\Bamboo::getEmployees();
$employeeIndex = \App\Bamboo::getEmployeeIndex(auth()->user()->email, $employees);
$view->with('employees', $employees);
$view->with('user', $employees['employees'][$employeeIndex]);
});
}
Is there a why for me to choose which function will be called in the SiteController based on the role (this is contained in the $user)?
I want to do something like this:
$method = $user->role === 'dev' ? 'index' : 'admin';
Route::get('/', "SiteController@{$method}");
Is this p
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wVrnn0
via IFTTT
Aucun commentaire:
Enregistrer un commentaire