*/ class SparePartFactory extends Factory { protected $model = SparePart::class; public function definition(): array { return [ 'article' => fake()->unique()->bothify('SP-####'), 'used_in_maf' => fake()->sentence(2), 'product_id' => null, 'note' => fake()->optional()->sentence(), 'purchase_price' => fake()->randomFloat(2, 100, 10000), 'customer_price' => fake()->randomFloat(2, 150, 15000), 'expertise_price' => fake()->randomFloat(2, 200, 20000), 'tsn_number' => fake()->optional()->numerify('TSN-####'), 'min_stock' => fake()->numberBetween(0, 10), ]; } public function withProduct(): static { return $this->state(fn (array $attributes) => [ 'product_id' => Product::factory(), ]); } public function withMinStock(int $minStock): static { return $this->state(fn (array $attributes) => [ 'min_stock' => $minStock, ]); } }