Generate dummy data in Laravel using Model Factory

Here are the steps needed to create dummy data

  • Lets create a model called Sample with migration file, using php artisan command
  • Run the migration by
  • Generate a factory The new factory will be placed in your database/factories directory.
  • Open the SampleFactory class and add
  • Create a seeder by using artisan command

  • Open the SamplesTableSeeder class file
  • Once the seeder is ready, we need to regenerate Composer’s autoloader using the dump-autoload command:

    then run either


Now you can see the records in samples table.

About the author

Janaki( - A Software developer with 9+ years of experience in multiple technology projects across web, mobile, and cloud applications with expertise in PHP, C#, MySQL, Web services and open source platforms.

Similar Posts

Leave a reply


Eye Test: * Time limit is exhausted. Please reload CAPTCHA.