]> BookStack Code Mirror - bookstack/blob - app/Activity/Models/Watch.php
Notifications: Linked watch functionality to UI
[bookstack] / app / Activity / Models / Watch.php
1 <?php
2
3 namespace BookStack\Activity\Models;
4
5 use BookStack\Permissions\Models\JointPermission;
6 use Carbon\Carbon;
7 use Illuminate\Database\Eloquent\Model;
8 use Illuminate\Database\Eloquent\Relations\HasMany;
9
10 /**
11  * @property int $id
12  * @property int $user_id
13  * @property int $watchable_id
14  * @property string $watchable_type
15  * @property int $level
16  * @property Carbon $created_at
17  * @property Carbon $updated_at
18  */
19 class Watch extends Model
20 {
21     protected $guarded = [];
22
23     public function watchable()
24     {
25         $this->morphTo();
26     }
27
28     public function jointPermissions(): HasMany
29     {
30         return $this->hasMany(JointPermission::class, 'entity_id', 'watchable_id')
31             ->whereColumn('favourites.watchable_type', '=', 'joint_permissions.entity_type');
32     }
33 }