build: initialize RetroHub with Laravel, Inertia, Vue, and Horizon
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Features\Games\Models;
|
||||
|
||||
use App\Features\Consoles\Models\Console;
|
||||
use App\Features\Settings\Models\SaveFile;
|
||||
use Database\Factories\GameFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Game extends Model
|
||||
{
|
||||
/** @use HasFactory<GameFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected static ?string $factory = GameFactory::class;
|
||||
|
||||
protected $fillable = [
|
||||
'console_id',
|
||||
'title',
|
||||
'slug',
|
||||
'igdb_id',
|
||||
'tgdb_id',
|
||||
'description',
|
||||
'release_year',
|
||||
'developer',
|
||||
'publisher',
|
||||
'genre',
|
||||
'rating',
|
||||
'cover_path',
|
||||
'thumbnail_path',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'rating' => 'decimal:1',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Game $game) {
|
||||
if (empty($game->slug)) {
|
||||
$game->slug = Str::slug($game->title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function console(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Console::class);
|
||||
}
|
||||
|
||||
public function romFiles(): HasMany
|
||||
{
|
||||
return $this->hasMany(RomFile::class);
|
||||
}
|
||||
|
||||
public function saveFiles(): HasMany
|
||||
{
|
||||
return $this->hasMany(SaveFile::class);
|
||||
}
|
||||
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'slug';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Features\Games\Models;
|
||||
|
||||
use Database\Factories\RomFileFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class RomFile extends Model
|
||||
{
|
||||
/** @use HasFactory<RomFileFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected static ?string $factory = RomFileFactory::class;
|
||||
|
||||
protected $fillable = [
|
||||
'game_id',
|
||||
'file_path',
|
||||
'file_name',
|
||||
'file_size',
|
||||
'file_hash',
|
||||
'region',
|
||||
'language',
|
||||
];
|
||||
|
||||
public function game(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Game::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user