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

Continued with database work for permissions overhaul

Added to the entity_permissions table with further required fields and indexes.
Wrote the code for checking permissions.
This commit is contained in:
Dan Brown
2016-04-23 18:14:26 +01:00
parent ea287ebf86
commit ada7c83e96
6 changed files with 186 additions and 182 deletions

View File

@ -73,6 +73,15 @@ abstract class Entity extends Ownable
return $this->restrictions->where('role_id', $role_id)->where('action', $action)->count() > 0;
}
/**
* Get the entity permissions this is connected to.
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function permissions()
{
return $this->morphMany(EntityPermission::class, 'entity');
}
/**
* Allows checking of the exact class, Used to check entity type.
* Cleaner method for is_a.
@ -81,7 +90,16 @@ abstract class Entity extends Ownable
*/
public static function isA($type)
{
return static::getClassName() === strtolower($type);
return static::getType() === strtolower($type);
}
/**
* Get entity type.
* @return mixed
*/
public static function getType()
{
return strtolower(static::getClassName());
}
/**