127 lines
4.5 KiB
PHP
127 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\User;
|
|
use App\Models\Vehicle;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class VehicleSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
$users = User::query()->orderBy('name')->orderBy('surname')->get();
|
|
|
|
if ($users->isEmpty()) {
|
|
return;
|
|
}
|
|
|
|
$sampleVehicles = [
|
|
[
|
|
'brand' => 'Toyota',
|
|
'model' => 'Corolla',
|
|
'registration_number' => 'DW1234A',
|
|
'user_id' => $users->first()->id,
|
|
'year' => 2021,
|
|
'purchase_date' => '2021-05-12',
|
|
'oc_expiry_date' => '2027-05-12',
|
|
'oil_change_km' => 12000,
|
|
'insurance_provider' => 'PZU',
|
|
'technical_inspection_date' => '2026-12-01',
|
|
'mileage_km' => 95000,
|
|
'status' => 'używany',
|
|
],
|
|
[
|
|
'brand' => 'Ford',
|
|
'model' => 'Transit',
|
|
'registration_number' => 'WA9876Z',
|
|
'user_id' => $users->get(1)->id ?? $users->first()->id,
|
|
'year' => 2019,
|
|
'purchase_date' => '2019-07-20',
|
|
'oc_expiry_date' => '2027-07-20',
|
|
'oil_change_km' => 8000,
|
|
'insurance_provider' => 'Warta',
|
|
'technical_inspection_date' => '2026-09-15',
|
|
'mileage_km' => 175000,
|
|
'status' => 'aktywny',
|
|
],
|
|
[
|
|
'brand' => 'BMW',
|
|
'model' => 'X5',
|
|
'registration_number' => 'PO1111A',
|
|
'user_id' => $users->last()->id,
|
|
'year' => 2022,
|
|
'purchase_date' => '2022-02-18',
|
|
'oc_expiry_date' => '2028-02-18',
|
|
'oil_change_km' => 15000,
|
|
'insurance_provider' => 'PZU',
|
|
'technical_inspection_date' => '2027-02-11',
|
|
'mileage_km' => 64000,
|
|
'status' => 'serwis',
|
|
],
|
|
[
|
|
'brand' => 'Mercedes',
|
|
'model' => 'Vito',
|
|
'registration_number' => 'GD2044K',
|
|
'user_id' => $users->first()->id,
|
|
'year' => 2020,
|
|
'purchase_date' => '2020-11-04',
|
|
'oc_expiry_date' => '2027-11-04',
|
|
'oil_change_km' => 10000,
|
|
'insurance_provider' => 'PZU',
|
|
'technical_inspection_date' => '2026-10-20',
|
|
'mileage_km' => 118500,
|
|
'status' => 'aktywny',
|
|
],
|
|
[
|
|
'brand' => 'Volkswagen',
|
|
'model' => 'Crafter',
|
|
'registration_number' => 'LU5567N',
|
|
'user_id' => $users->get(1)->id ?? $users->first()->id,
|
|
'year' => 2018,
|
|
'purchase_date' => '2018-06-15',
|
|
'oc_expiry_date' => '2026-12-15',
|
|
'oil_change_km' => 9000,
|
|
'insurance_provider' => 'Warta',
|
|
'technical_inspection_date' => '2026-08-30',
|
|
'mileage_km' => 214000,
|
|
'status' => 'serwis',
|
|
],
|
|
[
|
|
'brand' => 'Skoda',
|
|
'model' => 'Superb',
|
|
'registration_number' => 'TR9912R',
|
|
'user_id' => $users->last()->id,
|
|
'year' => 2023,
|
|
'purchase_date' => '2023-03-22',
|
|
'oc_expiry_date' => '2028-03-22',
|
|
'oil_change_km' => 18000,
|
|
'insurance_provider' => 'PZU',
|
|
'technical_inspection_date' => '2027-04-12',
|
|
'mileage_km' => 42000,
|
|
'status' => 'używany',
|
|
],
|
|
[
|
|
'brand' => 'Renault',
|
|
'model' => 'Traffic',
|
|
'registration_number' => 'WK3345P',
|
|
'user_id' => $users->first()->id,
|
|
'year' => 2017,
|
|
'purchase_date' => '2017-09-01',
|
|
'oc_expiry_date' => '2026-09-01',
|
|
'oil_change_km' => 11000,
|
|
'insurance_provider' => 'Hestia',
|
|
'technical_inspection_date' => '2026-11-05',
|
|
'mileage_km' => 188400,
|
|
'status' => 'sprzedany',
|
|
],
|
|
];
|
|
|
|
foreach ($sampleVehicles as $vehicle) {
|
|
Vehicle::firstOrCreate([
|
|
'registration_number' => $vehicle['registration_number'],
|
|
], $vehicle);
|
|
}
|
|
}
|
|
}
|