Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Learn to use Model Factories in Laravel 5.1
Oct 08, 2015 @ 15:46:21

On the Laravel News site there's a tutorial helping you learn to use Model factories in your Laravel 5.1+ application. These factories make it easy to create instances of "fake" models that can be interacted with as if they were the real thing.

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.

They provide a situation where these factories can solve a potential problem: making an application easier to test because of the (potentially) high volume of customers. He walks you through the creation of a new application and building out the models and matching migrations. Next up is the generation of the database seed values and, finally, the creation of the fake models and the code needed to connect it all together. The post ends with a look at using these factories to generate models in tests, creating them with simple data and some of the other features they offer.

tagged: model factory laravel fake tutorial testing introduction

Link: https://laravel-news.com/2015/10/learn-to-use-model-factories-in-laravel-5-1/


Trending Topics: