*/ class DeviceFactory extends Factory { protected $model = Device::class; /** * Define the model's default state. * * @return array */ public function definition(): array { $brands = [ 'estatal', 'nacional', ]; $year = fake()->numberBetween(2020, 2025); $randomNumber = fake()->unique()->numerify('######'); return [ 'brand' => fake()->randomElement($brands), 'serie' => strtoupper(fake()->bothify('??##')) . '-' . $year . '-' . $randomNumber, 'mac_address' => fake()->macAddress(), 'status' => fake()->boolean(85), // 85% activos ]; } /** * Indicate that the device is inactive. */ public function inactive(): static { return $this->state(fn (array $attributes) => [ 'status' => false, ]); } /** * Indicate that the device is active. */ public function active(): static { return $this->state(fn (array $attributes) => [ 'status' => true, ]); } /** * Indicate that the device is of a specific brand. */ public function brand(string $brand): static { return $this->state(fn (array $attributes) => [ 'brand' => $brand, ]); } }