1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Added a whole load of permission & role tests

This commit is contained in:
Dan Brown
2016-03-05 12:09:09 +00:00
parent 8e274a5a84
commit 268db6b1d0
9 changed files with 450 additions and 9 deletions

View File

@ -67,11 +67,12 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
/**
* Get all permissions belonging to a the current user.
* @param bool $cache
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
*/
public function permissions()
public function permissions($cache = true)
{
if(isset($this->permissions)) return $this->permissions;
if(isset($this->permissions) && $cache) return $this->permissions;
$this->load('roles.permissions');
$permissions = $this->roles->map(function($role) {
return $role->permissions;
@ -106,7 +107,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
*/
public function attachRoleId($id)
{
$this->roles()->attach([$id]);
$this->roles()->attach($id);
}
/**