*/ class InventoryFactory extends Factory { /** * Define the model's default state. * * @return array */ 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, ]); } }