1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Notifications: Linked watch functionality to UI

Got watch system working to an initial base state.
Moved some existing logic where it makes sense.
This commit is contained in:
Dan Brown
2023-08-02 13:14:00 +01:00
parent 8cdf3203ef
commit 9d149e4d36
13 changed files with 161 additions and 56 deletions

View File

@ -18,13 +18,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
*/
class Watch extends Model
{
protected static array $levelByOption = [
'default' => -1,
'ignore' => 0,
'new' => 1,
'updates' => 2,
'comments' => 3,
];
protected $guarded = [];
public function watchable()
{
@ -36,17 +30,4 @@ class Watch extends Model
return $this->hasMany(JointPermission::class, 'entity_id', 'watchable_id')
->whereColumn('favourites.watchable_type', '=', 'joint_permissions.entity_type');
}
/**
* @return string[]
*/
public static function getAvailableOptionNames(): array
{
return array_keys(static::$levelByOption);
}
public static function optionNameToLevel(string $option): int
{
return static::$levelByOption[$option] ?? -1;
}
}