@Ranjeet where is that code, please paste your full routes.php file.
May 28, 2015
6
Level 2
Routing according to roles
In my database of "Users" table, there is "role" column with 'admin' and 'client' as "Enum" types in routes.php i want to allow access to edit page for admin only not client so in routes.php i use like this routes.php
Route::get('login',['midddleware'=>'guest','uses'=>'AccountController@Login']);
$router->get('view/product','GoodsController@addProduct');
$router->post('view/product','GoodsController@storeProduct');
$router->get('home','GoodsController@viewAllProduct');
if(Auth::user()->role=='admin')
{
$router->get('edit',array(
'as'=>'edit',
'uses'=>'GoodsController@edit'));
}else{}
$router->get('delete/{id}','GoodsController@delete');
Route::get('my/products' ,'GoodsController@myProducts');
Route::get('accept/{id}',array(
'as'=>'accept-product',
'uses'=>'GoodsController@updateProduct'));
i have added following part to check roles
if(Auth::user()->role=='admin')
{
$router->get('edit',array(
'as'=>'edit',
'uses'=>'GoodsController@edit'));
}else{}
I have checked user is admin or not before redirecting to edit page but this is not working .How to route this?
Please or to participate in this conversation.