Source: stefanzweifel.dev

Local Environment Seeders in Laravel
https://laravel.com/docs/master/seeding are a feature of Laravel you don't read much about. I barely used them before 2022, but last year I found a perfect use case that I've now started to incorporate in all my projects: "Local Environment Seeders". Instead of only seeding data for a Category-model, the seeders generate users, teams, posts, purchases, subscriptions or what else is important in the application.

In Laravel apps using Jetstream with teams, I create and attach one or more default teams to the user. class LocalEnvironmentSeeder extends Seeder { public function run() { $this->createDefaultUser(); } protected function createDefaultUser(): self { User::factory()->create([ 'name' => 'system-user', 'email' => 'system@example.com', ]); return $this; }}
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