*/ protected $guarded = ['id']; /** * Get the releases associated with this movie. */ public function releases(): HasMany // @phpstan-ignore missingType.generics { return $this->hasMany(Release::class, 'imdbid', 'imdbid'); } public static function getAll(string $search = ''): mixed { $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $movie = Cache::get(md5($search)); if ($movie !== null) { return $movie; } $sql = self::query()->select('*'); if (! empty($search)) { // Search by both title and IMDB ID $sql->where(function ($query) use ($search) { $query->whereLike('title', '%'.$search.'%') ->orWhere('imdbid', $search); }); } $movie = $sql->paginate(config('nntmux.items_per_page')); Cache::put(md5($search), $movie, $expiresAt); return $movie; } }