Laravel Snippets: Useful Packages

I’ve got a library of go-to packages for Laravel projects that can knock days off a project. When the wheel is invented, developed, and proven in production, there’s no good business case to do it again.

A useful package is installed with Composer, compatible from Laravel 4 up to Laravel 5.*, and has little to no configuration, no learning curve, and no re-engineering to plug it in.

1. User and role based permissions – Entrust

Is the user an admin?

$user->hasRole('admin');

Does the user have permission to create a post?

$user->can('create-post');

OK, how about blanket protecting everything under /admin?

[ 'prefix' => '/admin', 'middleware' => ['admin', 'role:admin|root' ]]

Leave a Reply

Your email address will not be published. Required fields are marked *