$dates
$dates :
The main User class for Smarticops features.
Extends Authenticable which itself extends Eloquent User model.
So this class includs Authentication and Eloquent features.
To use a User class in your application, use the App\User class, which inherits this Smarticops\User class.
$hidden : array
The attributes that should be hidden for arrays.
| None found |
getRoles() : array
Get all the roles assigned to the user as an array of strings
| None found |
hasRole(string $roleName) : boolean
Checks if a user has a specific role
| string | $roleName | The name of the role to test for, case sensitive. |
true if the user has the role, false otherwise.
| None found |
is(string $roleName) : boolean
Just an alias for `hasRole()`.
| string | $roleName | The name of the role to test for, case sensitive. |
true if the user has the role.
| None found |
scopeHavingRole(mixed $query, $roleName)
Defines a new query scope.
Allows to access directly all the users having a specific role.
Method written as described in the Laravel documentation.
Usage example : User->havingRole('Student');
| mixed | $query | |
| $roleName |
| todo |
allow to select more than one role with the syntax 'role1|role2' |
|---|
assignRole(\Dvivier\Smarticops\Role|string $role = null, boolean $givePermissions = false) : boolean
Assigns a role to the user.
Since a user can have multiple roles, the user keeps the roles it had before being assigned a new role. To remove a role from a user, use User->revokeRole(). If the user already has the roles, the method does nothing and true is returned.
| \Dvivier\Smarticops\Role|string | $role | The Role instance, otherwise a string. Must exist before assigning. |
| boolean | $givePermissions | If set to true, after assigning the role, the method will also give to the user all the permissions associated to the role. |
true if the role was succesfully added or was already assigned false if the assignation failed or if role doesn't exist
| None found |
revokeRole( $role) : true
Removes the role from a user.
| $role | The role to revoke, object or string |
if (the user had the role AND it has not any more), false if the removal failed or the user didn't have the role
| None found |
fullName() : string
The full name of the user.
firstname + " " + last name
| None found |
loadPermissions() : \Dvivier\Smarticops\Collection
Loads all the permissions associated to the user from the database to the Session To avoid too many requests to the DB
of Permissions
| None found |
givePermission( $permissionCode, boolean $value = true) : boolean
Gives a specific permission to the user.
The permission must exist before giving it to the user. By default the permission is set to true, you may set it to false to explicitly mean that the user does NOT have that permission.
| $permissionCode | ||
| boolean | $value |
true if the permission was successfully given to the user or if the user already had this permission false if the permission doesn't exist
| None found |
removePermission( $permissionCode) : true
Removes a Permission from a user, specifying the permission by its code.
| $permissionCode | $string |
if the permission was removed successfully, false if the permission does not exists, or if the user does not have the permission.
| None found |
hasPermission( $permissionCode, $fromDB = false)
Tests if the user has a permission or not.
By default, the method looks only at the session where the permissions has been stored for the user currently logged in , Auth::user(). This allows to reduce the number of DB queries.
In most cases, there is no need to get info from database since the permissions are put in the session at login.
Pass true as 2nd argument if you're testing another user's permissions than the one who is logged in.
| $permissionCode | string the permission to test for |
|
| $fromDB | boolean (optional) whether or not do a request to the database |
| None found |