Files
crewli/api/app/Http/Requests/Api/V1/Artist/UpdateArtistRequest.php
bert.hausmans bb1bd8361a feat(timetable): 13 form requests for artist domain endpoints
Created under app/Http/Requests/Api/V1/Artist/, mirroring the
existing FormRequest pattern (final class, authorize() returns true,
controller-level Gate::authorize). One request per CRUD shape plus the
two domain-specific endpoints:

  artists                     create / update
  genres                      create / update (with org-scoped unique)
  stages                      create / update (with event-scoped unique)
  stages/order                ReorderStagesRequest — permutation check
  engagements                 create / update — per RFC §10.3, with
                              ContractRequiresFee + OptionExpiresInFuture
                              conditional rules wired
  performances                create / update — per §10.2; cross-FK
                              engagement.event_id ↔ event_id chain
                              enforced via withValidator closure;
                              update is non-placement only (placement
                              edits go through /timetable/move)
  timetable/move              per §10.4; resolves target_event_id from
                              target_stage_id + target_start_at via
                              stage_days, then reuses StageActiveOnEvent
                              + WithinEventBounds for downstream rules
  stages/{stage}/days         §10.5 matrix replace; each event_id must
                              equal stage.event_id (flat) or be sub-event
                              (festival)

Custom error messages in Dutch where user-facing. Cross-FK rules that
span request inputs (engagement vs event-id chain, day matrix sub-event
membership) live in withValidator after-closures so the rule cache is
stable per request.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 20:51:59 +02:00

45 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\Api\V1\Artist;
use App\Models\Artist;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
final class UpdateArtistRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
$artist = $this->route('artist');
$organisationId = $artist instanceof Artist
? $artist->organisation_id
: ($this->route('organisation')?->id ?? null);
return [
'name' => ['sometimes', 'required', 'string', 'max:120'],
'default_genre_id' => [
'sometimes', 'nullable', 'string', 'max:30',
Rule::exists('genres', 'id')->where('organisation_id', $organisationId),
],
'default_draw' => ['sometimes', 'nullable', 'integer', 'min:0'],
'star_rating' => ['sometimes', 'nullable', 'integer', 'between:1,5'],
'home_base_country' => ['sometimes', 'nullable', 'string', 'size:2', 'alpha'],
'agent_company_id' => [
'sometimes', 'nullable', 'string', 'max:30',
Rule::exists('companies', 'id')->where('organisation_id', $organisationId),
],
'notes' => ['sometimes', 'nullable', 'string', 'max:2000'],
];
}
}