In your routes files you create a group and defire before auth. If the user isn't logged in and attempts the route it will redirect them.
Route::group(array('before' => 'auth'), function()
{
//PROTECTED ROUTES HERE
Route::get('/browse', array('as'=>'browse', 'uses'=>'PageController@browse'));
Route::get('/search', array('as'=>'search', 'uses'=>'PageController@search'));
}
Let me try to give an example.
In zizaco entrust we have users, roles and permissions. In my view (index.blade.php), i have 3 buttons (show, edit,delete). Can i do something like: The user "A" with role "user" and permission "read", will only view the show button?
Find out how to do what i wanted, this is my solution. In my blade page:
<?php
if (Auth::user()->ability('Admin',array('read_col_x'),$options = array('validate_all' => true))) {
echo("<li><a href='#'><span class='glyphicon glyphicon-certificate'></span> Col_X</a></li>");
}
?>
Admin is the Role, read_col_x is the permission, with this only the users that have the role 'Admin' and permission 'read_col_x' can see that element
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community