CarsFromDromSeeder.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Database\Seeders;
  3. /*
  4. * CarsFromDromSeeder — 30 автомобилей с реальными данными с auto.drom.ru
  5. * Данные вынесены в database/seeders/data/cars_drom.php (файл возвращает массив).
  6. * steering: Москва → left; японские авто из Владивостока → right.
  7. */
  8. use App\Models\Car;
  9. use Illuminate\Database\Seeder;
  10. class CarsFromDromSeeder extends Seeder
  11. {
  12. public function run(): void
  13. {
  14. $cars = require __DIR__ . '/data/cars_drom.php';
  15. foreach ($cars as $data) {
  16. Car::create(array_merge($data, [
  17. 'status' => 'active',
  18. 'doors' => null,
  19. 'vin' => null,
  20. 'plate' => null,
  21. 'color_exterior' => null,
  22. 'color_interior' => null,
  23. 'generation' => null,
  24. 'owners_count' => null,
  25. 'customs_cleared' => false,
  26. 'accident_free' => false,
  27. 'pts' => null,
  28. 'price_usd' => null,
  29. 'price_vladivostok' => null,
  30. 'price_moscow' => null,
  31. 'price_negotiable' => false,
  32. 'options' => null,
  33. 'description' => null,
  34. 'photo_main' => null,
  35. 'photos_gallery' => null,
  36. ]));
  37. }
  38. $this->command->info('Залито ' . count($cars) . ' автомобилей с drom.ru');
  39. }
  40. }