3 namespace BookStack\Activity\Models;
5 use BookStack\Permissions\Models\JointPermission;
7 use Illuminate\Database\Eloquent\Model;
8 use Illuminate\Database\Eloquent\Relations\HasMany;
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
19 class Watch extends Model
21 protected static array $levelByOption = [
29 public function watchable()
34 public function jointPermissions(): HasMany
36 return $this->hasMany(JointPermission::class, 'entity_id', 'watchable_id')
37 ->whereColumn('favourites.watchable_type', '=', 'joint_permissions.entity_type');
43 public static function getAvailableOptionNames(): array
45 return array_keys(static::$levelByOption);
48 public static function optionNameToLevel(string $option): int
50 return static::$levelByOption[$option] ?? -1;