49 lines
2.0 KiB
PHP
49 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Customer;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Vehicle>
|
|
*/
|
|
class VehicleFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$makes = ['Toyota', 'Honda', 'Ford', 'Chevrolet', 'Nissan', 'BMW', 'Mercedes-Benz', 'Audi', 'Volkswagen', 'Hyundai'];
|
|
$models = [
|
|
'Toyota' => ['Camry', 'Corolla', 'RAV4', 'Highlander', 'Prius'],
|
|
'Honda' => ['Civic', 'Accord', 'CR-V', 'Pilot', 'Odyssey'],
|
|
'Ford' => ['F-150', 'Explorer', 'Focus', 'Mustang', 'Edge'],
|
|
'Chevrolet' => ['Silverado', 'Tahoe', 'Malibu', 'Equinox', 'Corvette'],
|
|
'Nissan' => ['Altima', 'Sentra', 'Rogue', 'Pathfinder', '370Z'],
|
|
];
|
|
|
|
$make = $this->faker->randomElement($makes);
|
|
$model = $this->faker->randomElement($models[$make] ?? ['Sedan', 'SUV', 'Coupe']);
|
|
|
|
return [
|
|
'customer_id' => Customer::factory(),
|
|
'vin' => strtoupper($this->faker->bothify('?????????########')),
|
|
'make' => $make,
|
|
'model' => $model,
|
|
'year' => $this->faker->numberBetween(2010, 2024),
|
|
'color' => $this->faker->colorName(),
|
|
'license_plate' => $this->faker->optional(0.8)->bothify('???-####'),
|
|
'engine_type' => $this->faker->randomElement(['4-Cylinder', 'V6', 'V8', 'Hybrid', 'Electric']),
|
|
'transmission' => $this->faker->randomElement(['Manual', 'Automatic', 'CVT']),
|
|
'mileage' => $this->faker->numberBetween(5000, 150000),
|
|
'notes' => $this->faker->optional(0.3)->paragraph(),
|
|
'status' => $this->faker->randomElement(['active', 'inactive']),
|
|
'last_service_date' => $this->faker->optional(0.7)->dateTimeBetween('-1 year', 'now'),
|
|
];
|
|
}
|
|
}
|