69 lines
2.4 KiB
PHP
69 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
|
use Spatie\Activitylog\Support\LogOptions;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property string $slug
|
|
* @property int $platform_id
|
|
* @property int $genre_id
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Entry> $entries
|
|
* @property-read int|null $entries_count
|
|
* @property-read \App\Models\Genre $genre
|
|
* @property-read \App\Models\Platform $platform
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game whereGenreId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game wherePlatformId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game whereSlug($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Game whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Game extends Model
|
|
{
|
|
|
|
use LogsActivity;
|
|
|
|
/**
|
|
* @var string[]
|
|
*/
|
|
protected $fillable = ['name', 'slug', 'platform_id', 'genre_id' ];
|
|
|
|
public function platform(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Platform::class);
|
|
}
|
|
|
|
public function genre(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Genre::class);
|
|
}
|
|
|
|
public function entries(): Game|\Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->hasMany(Entry::class);
|
|
}
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
{
|
|
return LogOptions::defaults()
|
|
->useLogName('game')
|
|
->logAll()
|
|
->logOnlyDirty()
|
|
->dontLogEmptyChanges()
|
|
->setDescriptionForEvent(fn(string $eventName) => "Game {$eventName}");
|
|
}
|
|
}
|