31 lines
941 B
PHP
31 lines
941 B
PHP
<?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),
|
|
];
|
|
}
|
|
}
|