Category: Laravel, PHP, javascript

· August 17, 2020 · ⋆ Laravel One of the many ways using which you can insert records (or seed your database) is by using the seeder classes which extend a base class called Illuminate\Database\Seeder in Laravel. For instance, if you want a seeder for say books table, you can generate it using the following command like so.

Now, the class only contains a method called run and this is where you can write queries to insert records like so.

For instance, if you want to generate, say 20 records based on this factory, you can use it in the BookSeeder like so.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners