Using a Laravel Factory State to Add a Spatie Role
I love the Spatie Laravel Permissions package. I use it in almost all of my Laravel projects.
When testing, I’ll need to set up users with various different roles and permissions. Usually, I’m using an Eloquent Factory in order to accomplish this.
But it’s a little different when you’re dealing with relationships. Let’s find out how.