image alt

Seeders Factories and Relationships

blog image

Tutorial 15

Link: PHP Laravel Intermediate tutorial | Seeders, Factories & Laravel Relationships - Part01 (In Sinhala) - YouTube

 

What are Seeders?

Laravel includes the ability to seed your database with data using seed classes. All seed classes are stored in the database/seeders directory. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.

Read more : Database: Seeding - Laravel - The PHP Framework For Web Artisans

What are Factories?

Laravel provides a variety of helpful tools and assertions to make it easier to test your database driven applications. In addition, Laravel model factories and seeders make it painless to create test database records using your application's Eloquent models and relationships. We'll discuss all of these powerful features in the following documentation.

Read more : Database Testing - Laravel - The PHP Framework For Web Artisans

What are Relationships?

Database tables are often related to one another. For example, a blog post may have many comments or an order could be related to the user who placed it. Eloquent makes managing and working with these relationships easy, and supports a variety of common relationships:

Read more : Eloquent: Relationships - Laravel - The PHP Framework For Web Artisans

php artisan make:seeder UserSeeder

php artisan make:factory PostFactory

php artisan db:seed

 

Facebook : https://www.facebook.com/CyberElysium

Instagram : https://www.instagram.com/cyber_elysium/

Twitter : https://twitter.com/CyberElysium

LinkedIn : https://www.linkedin.com/company/Cybe...

 

Visit our website for more details: https://cyberelysium.com/

Thanks for reading ❤

Ready to grow your business digitally?