'array']; } public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * @return array|null */ public static function filtersFor(?int $userId, string $view): ?array { if ($userId === null) { return null; } $row = static::query()->where('user_id', $userId)->where('view', $view)->first(); return $row === null ? null : array_map('strval', (array) $row->filters); } /** * @param array $filters */ public static function remember(int $userId, string $view, array $filters): void { static::query()->updateOrCreate(['user_id' => $userId, 'view' => $view], ['filters' => $filters]); } public static function forget(int $userId, string $view): void { static::query()->where('user_id', $userId)->where('view', $view)->delete(); } }