PHP Class Laratrust\Laratrust

Show file Open project: santigarcor/laratrust

Public Properties

Property Type Description
$app Illuminate\Foundation\Application Laravel application

Public Methods

Method Description
__construct ( Illuminate\Foundation\Application $app ) : void Create a new confide instance.
ability ( array | string $roles, array | string $permissions, $group, array $options = [] ) : boolean Check if the current user has a role or permission by its name
can ( string $permission, $group = null, $requireAll = false ) : boolean Check if the current user has a permission by its name
hasRole ( $role, $group = null, $requireAll = false ) : boolean Checks if the current user has a role by its name
routeNeedsPermission ( string $route, array | string $permissions, mixed $result = null, boolean $requireAll = true ) : mixed Filters a route for a permission or set of permissions.
routeNeedsRole ( string $route, array | string $roles, mixed $result = null, boolean $requireAll = true ) : mixed Filters a route for a role or set of roles.
routeNeedsRoleOrPermission ( string $route, array | string $roles, array | string $permissions, mixed $result = null, boolean $requireAll = false ) : void Filters a route for role(s) and/or permission(s).
user ( ) : Illuminate\Auth\UserInterface | null Get the currently authenticated user or null.

Method Details

__construct() public method

Create a new confide instance.
public __construct ( Illuminate\Foundation\Application $app ) : void
$app Illuminate\Foundation\Application
return void

ability() public method

Check if the current user has a role or permission by its name
public ability ( array | string $roles, array | string $permissions, $group, array $options = [] ) : boolean
$roles array | string The role(s) needed.
$permissions array | string The permission(s) needed.
$options array The Options.
return boolean

can() public method

Check if the current user has a permission by its name
public can ( string $permission, $group = null, $requireAll = false ) : boolean
$permission string Permission string.
return boolean

hasRole() public method

Checks if the current user has a role by its name
public hasRole ( $role, $group = null, $requireAll = false ) : boolean
return boolean

routeNeedsPermission() public method

If the third parameter is null then abort with status code 403. Otherwise the $result is returned.
public routeNeedsPermission ( string $route, array | string $permissions, mixed $result = null, boolean $requireAll = true ) : mixed
$route string Route pattern. i.e: "admin/*"
$permissions array | string The permission(s) needed
$result mixed i.e: Redirect::to('/')
$requireAll boolean User must have all permissions
return mixed

routeNeedsRole() public method

If the third parameter is null then abort with status code 403. Otherwise the $result is returned.
public routeNeedsRole ( string $route, array | string $roles, mixed $result = null, boolean $requireAll = true ) : mixed
$route string Route pattern. i.e: "admin/*"
$roles array | string The role(s) needed
$result mixed i.e: Redirect::to('/')
$requireAll boolean User must have all roles
return mixed

routeNeedsRoleOrPermission() public method

If the third parameter is null then abort with status code 403. Otherwise the $result is returned.
public routeNeedsRoleOrPermission ( string $route, array | string $roles, array | string $permissions, mixed $result = null, boolean $requireAll = false ) : void
$route string Route pattern. i.e: "admin/*"
$roles array | string The role(s) needed
$permissions array | string The permission(s) needed
$result mixed i.e: Redirect::to('/')
$requireAll boolean User must have all roles and permissions
return void

user() public method

Get the currently authenticated user or null.
public user ( ) : Illuminate\Auth\UserInterface | null
return Illuminate\Auth\UserInterface | null

Property Details

$app public property

Laravel application
public Application,Illuminate\Foundation $app
return Illuminate\Foundation\Application