Add follow system, activity feed, notifications, sitemap, caching, Scout search
This commit is contained in:
+15
-1
@@ -5,12 +5,14 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Spatie\Sluggable\HasSlug;
|
||||
use Spatie\Sluggable\SlugOptions;
|
||||
|
||||
class Game extends Model
|
||||
{
|
||||
use HasSlug;
|
||||
use HasSlug, Searchable;
|
||||
|
||||
protected $fillable = [
|
||||
'igdb_id', 'slug', 'title', 'summary', 'cover_url', 'cover_thumb_url',
|
||||
@@ -60,6 +62,15 @@ class Game extends Model
|
||||
return $this->hasMany(Review::class)->latest();
|
||||
}
|
||||
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'summary' => $this->summary,
|
||||
];
|
||||
}
|
||||
|
||||
public function scopePublished($query)
|
||||
{
|
||||
return $query->where('status', 'published');
|
||||
@@ -72,5 +83,8 @@ class Game extends Model
|
||||
'rating_avg' => $stats->avg ? round($stats->avg, 2) : null,
|
||||
'rating_count' => $stats->cnt ?? 0,
|
||||
]);
|
||||
|
||||
Cache::forget('home.top_rated');
|
||||
Cache::forget('games.top_rated.1');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user