*/ class FolderFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'user_id' => User::factory(), 'name' => fake()->unique()->words(2, true), 'color' => fake()->optional()->randomElement(Folder::COLORS), 'parent_id' => null, ]; } /** * Indicate that the folder belongs under the given parent folder. */ public function childOf(Folder $folder): static { return $this->state(fn (array $attributes) => [ 'parent_id' => $folder->id, 'user_id' => $folder->user_id, ]); } }