Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

242Studios's avatar

Seeding Problem - Array to string conversion

Hi,

I'm pretty new to Laravel and I just got in on the Laracasts Black Friday promotion and I'm so excited.

I'm hoping somebody can help me with this.

When I try to seed my database with a model factory, I'm getting the following error:

 [Illuminate\Database\QueryException]                                                                                                                                 
  Array to string conversion (SQL: insert into `proposals` (`user_id`, `title`, `prepared_for`, `phone`, `email`, `client_needs`, `number_of_pages`, `cms`, `analytic  
  s`, `hosting`, `domain_name`, `social_media`, `logo`, `mailing_list`, `facebook_profile`, `e_commerce`, `sitemap`, `total_time`, `discount_percentage`, `discount_d  
  ollar`, `additional_cost`, `updated_at`, `created_at`) values (1, SOMETHING interesting is., Casey Nikolaus, 852.908.3403 x3033, [email protected], Quo   
  deserunt rerum illum assumenda. Error modi nam velit. Sunt ab quaerat aut. Sunt voluptatum nobis voluptatem ut., 25, 1, 1, 1, 1, 0, 0, 0, 1, 1, http://lorempixel.c  
  om/640/480/022815, 44, 29, 677, 2016-11-26 17:34:29, 2016-11-26 17:34:29, ?))                                                                                        
                                                                                                                                                                       

                              
  [ErrorException]            
  Array to string conversion  

Here's a Gist showing my model factory code and also the migration I used to create the table:

https://gist.github.com/bahamagician/264ea2134357e03dfd6dff373850e394

I can provide additional info if needed. Where did I go wrong?

Thanks in advance for any assistance :)

-=Chris

0 likes
4 replies
242Studios's avatar
242Studios
OP
Best Answer
Level 8

Looks like it was

'client_needs' => $faker->paragraphs,

Paragraphs returns an array. I had to change it to "paragraph"

10 likes
flashadvocate's avatar

@bahamagician $faker->paragraphs() accepts two arguments optionally, the number of paragraphs, and a boolean for whether or not to return as an array or string

1 like
Mwangaben's avatar

You may use $faker->paragraph, or as described by @bahamagician $faker->paragraphs($number -of- paragraphs, $true -for-string return);

Please or to participate in this conversation.