Search code examples
phpdatabaselaravellaravel-5laravel-seeding

What is the difference between Model Factory and a DB seeder in Laravel?


What is the difference between Model Factory and a DB seeder in Laravel?


Solution

  • Database seeder is used to populate tables with data.

    Model factories is a convenient centralized place to define how your models should be populated with fake data.

    In seeder class you would leverage model factories, and model factories will most likely use another library to generate random fake data, such as fzaninotto/faker.