2021-06-26 15:23:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Auth\Permissions;
|
2018-09-25 11:30:50 +00:00
|
|
|
|
2022-10-09 16:14:11 +00:00
|
|
|
use BookStack\Auth\Role;
|
2018-09-25 11:30:50 +00:00
|
|
|
use BookStack\Model;
|
2022-10-09 16:14:11 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2022-10-08 12:52:59 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
2016-04-20 20:37:57 +00:00
|
|
|
|
2022-10-08 12:52:59 +00:00
|
|
|
/**
|
|
|
|
* @property int $id
|
|
|
|
* @property int $role_id
|
|
|
|
* @property int $entity_id
|
|
|
|
* @property string $entity_type
|
|
|
|
* @property boolean $view
|
|
|
|
* @property boolean $create
|
|
|
|
* @property boolean $update
|
|
|
|
* @property boolean $delete
|
|
|
|
*/
|
2016-04-20 20:37:57 +00:00
|
|
|
class EntityPermission extends Model
|
|
|
|
{
|
2022-10-08 12:52:59 +00:00
|
|
|
public const PERMISSIONS = ['view', 'create', 'update', 'delete'];
|
|
|
|
|
|
|
|
protected $fillable = ['role_id', 'view', 'create', 'update', 'delete'];
|
2016-05-01 20:20:50 +00:00
|
|
|
public $timestamps = false;
|
2016-04-20 20:37:57 +00:00
|
|
|
|
|
|
|
/**
|
2022-10-08 12:52:59 +00:00
|
|
|
* Get this restriction's attached entity.
|
2016-04-20 20:37:57 +00:00
|
|
|
*/
|
2022-10-08 12:52:59 +00:00
|
|
|
public function restrictable(): MorphTo
|
2016-04-20 20:37:57 +00:00
|
|
|
{
|
2016-05-01 20:20:50 +00:00
|
|
|
return $this->morphTo('restrictable');
|
2016-04-20 20:37:57 +00:00
|
|
|
}
|
2022-10-09 16:14:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the role assigned to this entity permission.
|
|
|
|
*/
|
|
|
|
public function role(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Role::class);
|
|
|
|
}
|
2016-04-20 20:37:57 +00:00
|
|
|
}
|