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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners