PHP Class Spatie\Permission\Models\Role

Inheritance: extends Illuminate\Database\Eloquent\Model, use trait Spatie\Permission\Traits\HasPermissions, use trait Spatie\Permission\Traits\RefreshesPermissionCache
Exibir arquivo Open project: spatie/laravel-permission Class Usage Examples

Public Properties

Property Type Description
$guarded array The attributes that aren't mass assignable.

Public Methods

Method Description
__construct ( array $attributes = [] ) Create a new Eloquent model instance.
findByName ( string $name ) : Role Find a role by its name.
hasPermissionTo ( string | Spatie\Permission\Models\Permission $permission ) : boolean Determine if the user may perform the given permission.
permissions ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany A role may be given various permissions.
users ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany A role may be assigned to various users.

Method Details

__construct() public method

Create a new Eloquent model instance.
public __construct ( array $attributes = [] )
$attributes array

findByName() public static method

Find a role by its name.
public static findByName ( string $name ) : Role
$name string
return Role

hasPermissionTo() public method

Determine if the user may perform the given permission.
public hasPermissionTo ( string | Spatie\Permission\Models\Permission $permission ) : boolean
$permission string | Spatie\Permission\Models\Permission
return boolean

permissions() public method

A role may be given various permissions.
public permissions ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
return Illuminate\Database\Eloquent\Relations\BelongsToMany

users() public method

A role may be assigned to various users.
public users ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
return Illuminate\Database\Eloquent\Relations\BelongsToMany

Property Details

$guarded public_oe property

The attributes that aren't mass assignable.
public array $guarded
return array