$attributes */ public function create(Organisation $organisation, array $attributes): Genre { return DB::transaction(function () use ($organisation, $attributes): Genre { $genre = new Genre($attributes); $genre->organisation_id = $organisation->id; $genre->is_active = $attributes['is_active'] ?? true; $genre->save(); return $genre->refresh(); }); } /** * @param array $attributes */ public function update(Genre $genre, array $attributes): Genre { unset($attributes['organisation_id']); $genre->fill($attributes); $genre->save(); return $genre->refresh(); } /** * Hard delete (genres are config — no soft-delete column on the table). * Blocks if any artist references this genre as `default_genre_id`. */ public function delete(Genre $genre): void { $referencingCount = Artist::query() ->where('default_genre_id', $genre->id) ->count(); if ($referencingCount > 0) { throw new GenreInUseException($genre, $referencingCount); } $genre->delete(); } }