3 namespace BookStack\Activity\Models;
5 use BookStack\Activity\WatchLevels;
6 use BookStack\Permissions\Models\JointPermission;
8 use Illuminate\Database\Eloquent\Model;
9 use Illuminate\Database\Eloquent\Relations\HasMany;
10 use Illuminate\Database\Eloquent\Relations\MorphTo;
14 * @property int $user_id
15 * @property int $watchable_id
16 * @property string $watchable_type
17 * @property int $level
18 * @property Carbon $created_at
19 * @property Carbon $updated_at
21 class Watch extends Model
23 protected $guarded = [];
25 public function watchable(): MorphTo
27 return $this->morphTo();
30 public function jointPermissions(): HasMany
32 return $this->hasMany(JointPermission::class, 'entity_id', 'watchable_id')
33 ->whereColumn('watches.watchable_type', '=', 'joint_permissions.entity_type');
36 public function getLevelName(): string
38 return WatchLevels::levelValueToName($this->level);
41 public function ignoring(): bool
43 return $this->level === WatchLevels::IGNORE;