1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
$user->hasRole('owner'); $user->hasRole('admin'); $user->can('edit-user'); $user->can('create-post');
$user->hasRole(['owner', 'admin']); $user->hasRole(['owner', 'admin'], true); $user->can(['edit-user', 'create-post']); $user->can(['edit-user', 'create-post'], true);
$user->can("admin.*");
$user->can("*_users");
Entrust::hasRole('role-name'); Entrust::can('permission-name');
Auth::user()->hasRole('role-name'); Auth::user()->can('permission-name');
$options = array( 'validate_all' => true, 'return_type' => 'both' );
list($validate, $allValidations) = $user->ability( array('admin', 'owner'), array('create-post', 'edit-user'), $options );
var_dump($validate);
var_dump($allValidations);
@role('admin') <p>This is visible to users with the admin role. Gets translated to \Entrust::role('admin')</p> @endrole
@permission('manage-admins') <p>This is visible to users with the given permissions. Gets translated to \Entrust::can('manage-admins'). The @can directive is already taken by core laravel authorization package, hence the @permission directive instead.</p> @endpermission
@ability('admin,owner', 'create-post,edit-user') <p>This is visible to users with the given abilities. Gets translated to \Entrust::ability('admin,owner', 'create-post,edit-user')</p> @endability
|