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