first&last
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\EquipmentCondition;
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\Equipment;
|
||||
use App\Models\EquipmentCategory;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class EquipmentSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$categories = EquipmentCategory::query()->get();
|
||||
$clients = User::query()->where('role', UserRole::CLIENT)->get();
|
||||
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$category = $categories->random();
|
||||
$client = $clients->random();
|
||||
|
||||
Equipment::query()->updateOrCreate(
|
||||
['inventory_number' => sprintf('INV-%04d', $i)],
|
||||
[
|
||||
'name' => fake()->randomElement([
|
||||
'Ноутбук Dell Latitude',
|
||||
'HP ProDesk',
|
||||
'Cisco Router',
|
||||
'Brother MFC Printer',
|
||||
'Lenovo ThinkPad',
|
||||
]).' '.$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(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user