Remove Faker usage from seeders
This commit is contained in:
@@ -16,6 +16,24 @@ class EquipmentSeeder extends Seeder
|
||||
$categories = EquipmentCategory::query()->get();
|
||||
$clients = User::query()->where('role', UserRole::CLIENT)->get();
|
||||
|
||||
$names = [
|
||||
'Ноутбук Dell Latitude',
|
||||
'HP ProDesk',
|
||||
'Cisco Router',
|
||||
'Brother MFC Printer',
|
||||
'Lenovo ThinkPad',
|
||||
];
|
||||
|
||||
$conditions = array_map(fn (EquipmentCondition $case) => $case->value, EquipmentCondition::cases());
|
||||
|
||||
$notes = [
|
||||
'Оборудование используется в штатном режиме.',
|
||||
'Требуется периодическая профилактика.',
|
||||
'Закреплено за пользователем в рамках эксплуатации.',
|
||||
'Используется для выполнения рабочих задач.',
|
||||
'Находится в исправном состоянии.',
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$category = $categories->random();
|
||||
$client = $clients->random();
|
||||
@@ -23,20 +41,14 @@ class EquipmentSeeder extends Seeder
|
||||
Equipment::query()->updateOrCreate(
|
||||
['inventory_number' => sprintf('INV-%04d', $i)],
|
||||
[
|
||||
'name' => fake()->randomElement([
|
||||
'Ноутбук Dell Latitude',
|
||||
'HP ProDesk',
|
||||
'Cisco Router',
|
||||
'Brother MFC Printer',
|
||||
'Lenovo ThinkPad',
|
||||
]).' '.$i,
|
||||
'name' => $names[($i - 1) % count($names)].' '.$i,
|
||||
'serial_number' => sprintf('SN-%08d', 10000000 + $i),
|
||||
'category_id' => $category->id,
|
||||
'client_id' => $client->id,
|
||||
'purchase_date' => now()->subMonths(rand(6, 48))->toDateString(),
|
||||
'warranty_until' => now()->addDays(rand(-90, 365))->toDateString(),
|
||||
'condition' => fake()->randomElement(EquipmentCondition::cases())->value,
|
||||
'notes' => fake()->sentence(),
|
||||
'condition' => $conditions[($i - 1) % count($conditions)],
|
||||
'notes' => $notes[($i - 1) % count($notes)],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user