Support the ongoing development of Laravel.io →
Security Views Forms
Last updated 2 years ago.
0

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'));
}
Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.