first commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Character;
|
||||
use App\Models\Inventory;
|
||||
use App\Models\Item;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Inventory>
|
||||
*/
|
||||
class InventoryFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'character_id' => Character::factory(),
|
||||
'item_id' => Item::factory(),
|
||||
'quantity' => $this->faker->numberBetween(1, 10),
|
||||
'equipped' => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an equipped item.
|
||||
*/
|
||||
public function equipped(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'equipped' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create with a specific quantity.
|
||||
*/
|
||||
public function withQuantity(int $quantity): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'quantity' => $quantity,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user