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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners