Black Friday: the Laravel testing course is $149 instead of $249, through Dec 7. See the course →
logo

Using factories with more than one relationship

Sometimes you can't follow the typical naming convention

Joel Clermont
Joel Clermont
2026-01-09

From our daily Laravel tips email. Get the next one in your inbox.

Laravel's factory for() helper is great for setting up relationships. But when two relationships point to the same model, conventions alone won't cut it.

In this video, I show how we can still use the nice fluent factory syntax to set up our test data.

Watch Now (4 min)

And after watching, don't forget to subscribe to our YouTube channel, so you don't miss future videos.

Here to help,

Joel

P.S. Want to level up your Laravel testing skills? Check out our testing workshop.

Want a tip like this in your inbox every weekday?

Each one takes less than 2 minutes to read. Join 4,000+ Laravel developers who already get them.

email
No spam. Only real-world advice.
Toss a coin in the jar if you found this helpful.