Laravel Roles and Authentication for Routes

I want to archive the following

User entries β†’ Assigning privileges from the database β†’ They can only see allowed routes

So far I have managed to contact us:

$user = Usercredential::where('username','=',Auth::user()->username)->get(); foreach ($user as $u ) { $status = $u->userstatus; $userPriv = $u->userpriviledge; if ($status == 0){ Session::put('user_priv',$userPriv); } else{ return Redirect::to_route('home')->with('message','Inactive users cannot login'); } 

Which checks the status of the user if he is active or inactive, and then saves the privilege in my session. What's next? How to protect your routes?

thanks

+2
source share
2 answers

For those who are looking for this solution in the future

http://net.tutsplus.com/tutorials/php/build-web-apps-from-scratch-with-laravel-filters-validations-and-files/

It will be very helpful, thanks Rodry for your pointer. I appreciate.

+1
source

I recommend you the Laravel 4: ENTRUST package , which provides a way to add role

+4
source

All Articles