build: initialize RetroHub with Laravel, Inertia, Vue, and Horizon
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Features\Consoles\Models\Console;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ConsoleFactory extends Factory
|
||||
{
|
||||
protected $model = Console::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->words(2, true);
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => fake()->unique()->slug(),
|
||||
'rom_extensions' => [['nes']],
|
||||
'igdb_platform_id' => fake()->optional()->randomNumber(3),
|
||||
'tgdb_platform_id' => fake()->optional()->randomNumber(4),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Features\Consoles\Models\Console;
|
||||
use App\Features\Games\Models\Game;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class GameFactory extends Factory
|
||||
{
|
||||
protected $model = Game::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$title = fake()->unique()->words(3, true);
|
||||
|
||||
return [
|
||||
'console_id' => Console::factory(),
|
||||
'title' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'description' => fake()->optional()->paragraph(),
|
||||
'release_year' => fake()->optional()->year(),
|
||||
'developer' => fake()->optional()->company(),
|
||||
'publisher' => fake()->optional()->company(),
|
||||
'genre' => fake()->optional()->randomElement(['Action', 'RPG', 'Platformer', 'Puzzle', 'Sports']),
|
||||
'rating' => fake()->optional(0.7)->randomFloat(1, 0, 10),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Features\Games\Models\Game;
|
||||
use App\Features\Games\Models\RomFile;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class RomFileFactory extends Factory
|
||||
{
|
||||
protected $model = RomFile::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$filename = fake()->word().'.nes';
|
||||
|
||||
return [
|
||||
'game_id' => Game::factory(),
|
||||
'file_path' => "roms/nes/{$filename}",
|
||||
'file_name' => $filename,
|
||||
'file_size' => fake()->numberBetween(100000, 10000000),
|
||||
'file_hash' => hash('sha256', fake()->uuid()),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Features\Games\Models\Game;
|
||||
use App\Features\Settings\Models\SaveFile;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SaveFileFactory extends Factory
|
||||
{
|
||||
protected $model = SaveFile::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$filename = fake()->word().'.srm';
|
||||
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'game_id' => Game::factory(),
|
||||
'file_path' => "saves/{$filename}",
|
||||
'file_name' => $filename,
|
||||
'file_size' => fake()->numberBetween(1000, 100000),
|
||||
'last_synced_at' => fake()->optional()->dateTime(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
protected $model = User::class;
|
||||
|
||||
protected static ?string $password;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Features\Settings\Models\UserSetting;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class UserSettingFactory extends Factory
|
||||
{
|
||||
protected $model = UserSetting::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'setting_key' => fake()->unique()->word(),
|
||||
'setting_value' => fake()->optional()->word(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user