2025-10-23 17:01:49 -06:00

68 lines
1.5 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Device;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Device>
*/
class DeviceFactory extends Factory
{
protected $model = Device::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
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,
]);
}
}