*/ final class ArtistFactory extends Factory { /** @return array */ public function definition(): array { $name = fake()->unique()->company().' '.fake()->randomElement(['Live', 'Sound', 'Project', 'Collective', 'DJ Set']); return [ 'organisation_id' => Organisation::factory(), 'name' => $name, 'slug' => Str::slug($name).'-'.Str::lower(Str::random(4)), 'default_genre_id' => null, 'default_draw' => fake()->numberBetween(50, 5000), 'star_rating' => fake()->numberBetween(1, 5), 'home_base_country' => fake()->randomElement(['NL', 'BE', 'DE', 'FR', 'UK']), 'agent_company_id' => null, 'notes' => null, ]; } public function withGenre(?Genre $genre = null): static { return $this->state(function (array $attrs) use ($genre): array { $resolved = $genre ?? Genre::factory()->create([ 'organisation_id' => $attrs['organisation_id'], ]); return ['default_genre_id' => $resolved->id]; }); } public function withAgent(?Company $company = null): static { return $this->state(function (array $attrs) use ($company): array { $resolved = $company ?? Company::factory()->create([ 'organisation_id' => $attrs['organisation_id'], 'type' => 'agency', ]); return ['agent_company_id' => $resolved->id]; }); } }