]> BookStack Code Mirror - bookstack/blob - app/Actions/Favourite.php
Added force option for update-url command
[bookstack] / app / Actions / Favourite.php
1 <?php
2
3 namespace BookStack\Actions;
4
5 use BookStack\Auth\Permissions\JointPermission;
6 use BookStack\Model;
7 use Illuminate\Database\Eloquent\Relations\HasMany;
8 use Illuminate\Database\Eloquent\Relations\MorphTo;
9
10 class Favourite extends Model
11 {
12     protected $fillable = ['user_id'];
13
14     /**
15      * Get the related model that can be favourited.
16      */
17     public function favouritable(): MorphTo
18     {
19         return $this->morphTo();
20     }
21
22     public function jointPermissions(): HasMany
23     {
24         return $this->hasMany(JointPermission::class, 'entity_id', 'favouritable_id')
25             ->whereColumn('favourites.favouritable_type', '=', 'joint_permissions.entity_type');
26     }
27 }