Skip to content
Advertisement

Laravel how to create a seeder based on array

How can I create a laravel-seeder based on an array?

I have an array like this:

JavaScript

So instead of doing like this

JavaScript

for each entry, I was hoping there might be another way to achieve that?

Advertisement

Answer

Option A)

JavaScript

Option B)

JavaScript

Note: Insert doesn’t automatically populate the timestamp columns.

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