I use https://laravel.com/docs/10.x/eloquent-factories quite extensively. Here's an https://peterbabic.dev/blog/convenient-relationship-factories-in-laravel-8/, in case you are interested.

The current docs show the following example for using Factory States: state(function (array $attributes) { return [ 'account_status' => 'suspended', ]; }); }} Now enable factories using HasFactory trait on the User model: suspended()->create(); Pretty useful and pretty self-explanatory.

Now take a look at the factory() method: */ public static function factory($count = null, $state = []) { $factory = static::newFactory()?: Factory::factoryForModel(get_called_class()); return $factory ->count(is_numeric($count)?
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