]> BookStack Code Mirror - bookstack/blob - app/Auth/Permissions/EntityPermission.php
603cf61ad64ca1e6252f44b22d6981de3310a1aa
[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
9 /**
10  * @property int $id
11  * @property int $role_id
12  * @property int $entity_id
13  * @property string $entity_type
14  * @property boolean $view
15  * @property boolean $create
16  * @property boolean $update
17  * @property boolean $delete
18  */
19 class EntityPermission extends Model
20 {
21     public const PERMISSIONS = ['view', 'create', 'update', 'delete'];
22
23     protected $fillable = ['role_id', 'view', 'create', 'update', 'delete'];
24     public $timestamps = false;
25     protected $hidden = ['entity_id', 'entity_type', 'id'];
26     protected $casts = [
27         'view' => 'boolean',
28         'create' => 'boolean',
29         'read' => 'boolean',
30         'update' => 'boolean',
31         'delete' => 'boolean',
32     ];
33
34     /**
35      * Get the role assigned to this entity permission.
36      */
37     public function role(): BelongsTo
38     {
39         return $this->belongsTo(Role::class);
40     }
41 }