1 week ago

Data truncated - $faker->randomElements

Posted 1 week ago by Kemped

I created a factory and want to generate randomElements from an array. However, when I run the factory in tinker I get "Array to string conversion error". Can someone explain why?

This is the the column in the table

$table->enum('interest_tags', ['php', 'javascript', 'vue']);

And I generate randomElements from the array like this:

'interest_tags' => $faker->randomElements(['php', 'javascript', 'vue'], 2),

Am I doing something wrong here?

Please sign in or create an account to participate in this conversation.