Category: Laravel

Attempting to utilise the new class based factories had me scratching my head for the best part of an afternoon. In the background Laravel is looking in the application Factories folder and so doesn’t see the ones in your package.

If you want to go down the rabbit hole start in Illuminate\Database\Eloquent\Factories\HasFactory trait and follow it to Illuminate\Database\Eloquent\Factories speciallycheck out resolveFactoryName on Line 680 Illuminate\Database\Eloquent\Factoriesfor a . There are two approaches which I’ve had success with.

Within the Models you wish to have Factories you add the following method with the full path to the Models Factory.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners