First announcement of today: a beautiful way to organize your ACL logic in Laravel. Available immediately! http://t.co/kKDOVWiWRO ?
— Laravel (@laravelphp) August 31, 2015
Already retweeted and favorited by hundreds of Laravel fans, this feature adds some new functionality to Auth mechanism. Here are just a few example from new official documentation:
New Gate facade:
if (Gate::forUser($user)->allows('update-post', $post)) { // }
if ($request->user()->can('update-post', $post)) { // ... Update post }
@can('update-post', $post) Edit Post @endcan
return Gate::allows('update', Post::findOrFail($postId));
php artisan make:policy PostPolicy
class PostPolicy { public function update(User $user, Post $post) { return $user->id === $post->user_id; } }
No comments or questions yet...