Using Factory sequences in Laravel original
One of the things I really like about modern Laravel projects, are the new model factories introduced in Laravel 8.
Posts tagged with factories
One of the things I really like about modern Laravel projects, are the new model factories introduced in Laravel 8.
– stefanzweifel.io - submitted by Stefan Zweifel
A quick intro on how to use states for "nested" Database Factories. The examples covers the Models created by laravel/cashier-paddle package.
Read more [stefanzweifel.io]
Join 9,500+ smart developers
Every month I share what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
🕵️♂️ Just discovered "->optional()" in $faker for my Laravel factories.
— Caleb Porzio (@calebporzio) January 18, 2020
Check it out.
Did you already know about this? pic.twitter.com/MrVETY7i3f
Read more [twitter.com]
? Laravel tip: Use your defined Eloquent relationships when you Factory models.
— Rasmus C Nielsen (@rasmuscnielsen) March 4, 2019
This can save you many lines of code and make your tests much more eloquent.
Simply install this package: https://t.co/6XNeQZk40T pic.twitter.com/f4T5xayL5X
Read more [twitter.com]
? Did you know you could use the afterCreating and lots of other "after" callbacks on Eloquent Factories to create additional models in Laravel? https://t.co/XejFph55zO #Laravel #PHP pic.twitter.com/oc8BfpEPqN
— Dries Vints (@driesvints) May 15, 2018
Read more [twitter.com]
John Bonaccorsi, a developer from Tighten, wrote some good ways of structuring model factories in a Laravel app.
Thanks to class-based model factories, our test setup went from being a bloated mess to simple and succinct. The optional fluent methods give us flexibility and make it obvious when we are intentionally changing our world. Should you read this blog post and immediately go and update all of your model factories to be class-based instead? Of course not! But if you begin to notice your tests feeling top heavy, class-based model factories may be the tool to reach for.
https://tighten.co/blog/tidy-up-your-tests-with-class-based-model-factories