Laravel 9 is fresh out the door, and it contains a small contribution of mine: a new callOnce method for database seeders. It solves a problem with seeders I’ve had for a long time, and thanks to http://twitter.com/brendt_gd/status/1465210141192634370 and https://twitter.com/rubenvanassche’s input I was able to propose a lightweight solution.
There are users (than can log in and publish posts), posts, pages, and categories.
You could have PostSeeder seed its own users and categories, but then DatabaseSeeder is seeding a bunch of unnecessary data.
class PostSeeder extends Seeder { public function run() { $this->callOnce([ UserSeeder::class, CategorySeeder::class, ]); }} class PageSeeder extends Seeder { public function run() { $this->callOnce([ CategorySeeder::class, ]); }}