mardi 29 septembre 2015

Laravel Authorization for Eloquent collection

How to apply laravel Gate (http://ift.tt/1hOo5aK) for an eloquent collection.

It works for single item like below

$post = Post::findOrFail($id);

if ($user->cannot('view-post', $post)) {
   abort(403);
}

But not working for a collection. Is it possible to filter the collection using Gate and return a collection?

$posts = Post::all();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire