How to apply laravel Gate ( http://laravel.com/docs/5.1/authorization ) for an eloquent collection.
It works for a single item as below
$post = Post::findOrFail($id); if ($user->cannot('view-post', $post)) { abort(403); }
But does not work for the collection. Is it possible to filter a collection using Gate and return the collection?
$posts = Post::all();
source share