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

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