]> BookStack Code Mirror - bookstack/blob - app/Auth/Permissions/EntityPermission.php
32ebc440d1dccc0b9274fd935531498dd23cb857
[bookstack] / app / Auth / Permissions / EntityPermission.php
1 <?php
2
3 namespace BookStack\Auth\Permissions;
4
5 use BookStack\Auth\Role;
6 use BookStack\Model;
7 use Illuminate\Database\Eloquent\Relations\BelongsTo;
8 use Illuminate\Database\Eloquent\Relations\MorphTo;
9
10 /**
11  * @property int $id
12  * @property int $role_id
13  * @property int $entity_id
14  * @property string $entity_type
15  * @property boolean $view
16  * @property boolean $create
17  * @property boolean $update
18  * @property boolean $delete
19  */
20 class EntityPermission extends Model
21 {
22     public const PERMISSIONS = ['view', 'create', 'update', 'delete'];
23
24     protected $fillable = ['role_id', 'view', 'create', 'update', 'delete'];
25     public $timestamps = false;
26
27     /**
28      * Get this restriction's attached entity.
29      */
30     public function restrictable(): MorphTo
31     {
32         return $this->morphTo('restrictable');
33     }
34
35     /**
36      * Get the role assigned to this entity permission.
37      */
38     public function role(): BelongsTo
39     {
40         return $this->belongsTo(Role::class);
41     }
42 }