Skip to content
Advertisement

IlluminateDatabaseGrammar::parameterize(): Argument #1 ($values) must be of type array, string given

I am trying to Seed a database using a Model Factory in Laravel but am seeing this error on the terminal.

JavaScript

From the multiple solutions I have tried, it seems the issue is at the faker-generated content level, but I need that faker content for the factory to work as intended.

Below are the Factory and Migration classes that will help you when trying to find the solution.

Here is my factory class

JavaScript

Here is the migration for the Parking table

JavaScript

It is worth noting am using Laravel v9.24.0, PHP v8.1.0, and MySQL v8.0.27.

What might be the cause of my error?

Advertisement

Answer

The name field of your table is defined as a string, however, the words method of faker returns an array.

Supplying the words method with true as a second argument will return two words as a string.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement