Why is Laravel Eloquent generating SQL without quotes?

I am trying to run sudo php artisan migrate db:seedLaravel on my installation and get the following error:

  [Illuminate\Database\QueryException]                                                                                                          
  Array to string conversion (SQL: insert into `sponsor_phones` (`phone_number`, `type`, `is_primary`, `sponsor_id`, `updated_at`, `created_at  
  `) values (247-216-6255 x4356, Home, 1, 101, 2017-05-30 23:31:59, 2017-05-30 23:31:59))                           

It seems that SQL Eloquent creates missing quotes for the seeds where they need to be. Adding quotes to the right places (below) allows him to run.

insert into 
`sponsor_phones` 
(`phone_number`,
 `type`, 
 `is_primary`, 
 `sponsor_id`, 
 `updated_at`, 
 `created_at`
 ) 
  values 
  (
  '(732) 540-9730', 
  'Busi', 
  0,
  51, 
  '2017-05-27 21:53:44', 
  '2017-05-27 21:53:44');

I'm not sure what causes this error, and finding the reasons why Eloquent does not add citations does not seem to produce any useful results.

I have a repository so you can watch it (and because it needs it anyway as an open source project.)

+4
source share
1 answer

. ModelFactory.php, getTypePhone, getTypeEmail getTypeAddress

return $faker->randomElements(array('Work', 'Cell', 'Home', "VoIP"));

$faker->randomElements . $faker->randomElement, .

return $faker->randomElement(array('Work', 'Cell', 'Home', "VoIP"));
+1

Source: https://habr.com/ru/post/1678207/


All Articles