Model factories are a great feature of Laravel that will help us get information into our database. Normally we would create a list of users and then insert them into our database using a seeder.
Here's an example of inserting data into our database without model factories:
$users = [ ['name' => 'Chris', 'email' => 'firstname.lastname@example.org'], ['name' => 'Nick', 'email' => 'email@example.com'], ['name' => 'Holly', 'email' => 'firstname.lastname@example.org'], ]; foreach ($users as $user) App\User::create($user);
Here's the example with model factories:
Table of Contents