Model Factories

Introduction to Seeding Data in Testing
Laravel Tutorials / April 08, 2017

Introduction to Seeding Data in Testing

Since seeding was released in Laravel 5.1, testing has become easier and quicker. You can have ten users with each having a post or 1000 users with one or more posts inserted before the testing begins. In this tutorial, you will create a test case to test the user model and a seeder to seed …

In Laravel 5.3.17, Model Factories now includes states
News / October 06, 2016

In Laravel 5.3.17, Model Factories now includes states

New in Laravel 5.3.17 is an improvement to Model Factories that you allows to define different “states” for a factory. For example pretend you have a simple faker for creating a User: $factory->define(App\User::class, function (Faker\Generator $faker) { return [ ‘name’ => $faker->name, ’email’ => $faker->safeEmail, ]; }); Now you want to have the ability to … Read more…

Laravel Packages / March 29, 2016

Automatically Create Model Factories

Laravel Test Factory Generator is a new package by Marcel Pociot that generates model factories from your existing models and database structure. Once installed it gives you a new Artisan command to generate the model factories: php artisan test-factory-helper:generate This command will then look through all your models, create test factories, and save them in … Continue reading Read more…

Learn to use Model Factories in Laravel
Laravel Tutorials / October 06, 2015

Learn to use Model Factories in Laravel

Laravel 5.1 comes with a feature called model factories that are designed to allow you to quickly build out “fake” models.

These have several use cases with the two biggest being–testing and database seeding. Let’s take a deeper look at this feature by building out the beginning of a little fictional app.

Read more…