1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Major permission naming refactor and database migration cleanup

This commit is contained in:
Dan Brown
2016-05-01 21:20:50 +01:00
parent 05666efda9
commit 75a4fc905b
42 changed files with 481 additions and 351 deletions

View File

@ -43,7 +43,7 @@ abstract class Entity extends Ownable
*/
public function activity()
{
return $this->morphMany('BookStack\Activity', 'entity')->orderBy('created_at', 'desc');
return $this->morphMany(Activity::class, 'entity')->orderBy('created_at', 'desc');
}
/**
@ -51,15 +51,15 @@ abstract class Entity extends Ownable
*/
public function views()
{
return $this->morphMany('BookStack\View', 'viewable');
return $this->morphMany(View::class, 'viewable');
}
/**
* Get this entities restrictions.
*/
public function restrictions()
public function permissions()
{
return $this->morphMany('BookStack\Restriction', 'restrictable');
return $this->morphMany(EntityPermission::class, 'restrictable');
}
/**
@ -70,7 +70,7 @@ abstract class Entity extends Ownable
*/
public function hasRestriction($role_id, $action)
{
return $this->restrictions()->where('role_id', '=', $role_id)
return $this->permissions()->where('role_id', '=', $role_id)
->where('action', '=', $action)->count() > 0;
}
@ -86,12 +86,12 @@ abstract class Entity extends Ownable
}
/**
* Get the entity permissions this is connected to.
* Get the entity jointPermissions this is connected to.
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function permissions()
public function jointPermissions()
{
return $this->morphMany(EntityPermission::class, 'entity');
return $this->morphMany(JointPermission::class, 'entity');
}
/**