feat: fase 2 backend — crowd types, persons, sections, shifts, invite flow
- Crowd Types + Persons CRUD (73 tests) - Festival Sections + Time Slots + Shifts CRUD met assign/claim flow (84 tests) - Invite Flow + Member Management met InvitationService (109 tests) - Schema v1.6 migraties volledig uitgevoerd - DevSeeder bijgewerkt met crowd types voor testorganisatie
This commit is contained in:
71
api/app/Http/Resources/Api/V1/ShiftResource.php
Normal file
71
api/app/Http/Resources/Api/V1/ShiftResource.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\Api\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class ShiftResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'festival_section_id' => $this->festival_section_id,
|
||||
'time_slot_id' => $this->time_slot_id,
|
||||
'location_id' => $this->location_id,
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'instructions' => $this->instructions,
|
||||
'coordinator_notes' => $this->when(
|
||||
$this->shouldShowCoordinatorNotes($request),
|
||||
$this->coordinator_notes,
|
||||
),
|
||||
'slots_total' => $this->slots_total,
|
||||
'slots_open_for_claiming' => $this->slots_open_for_claiming,
|
||||
'is_lead_role' => $this->is_lead_role,
|
||||
'report_time' => $this->report_time,
|
||||
'actual_start_time' => $this->actual_start_time,
|
||||
'actual_end_time' => $this->actual_end_time,
|
||||
'allow_overlap' => $this->allow_overlap,
|
||||
'status' => $this->status,
|
||||
'filled_slots' => $this->filled_slots,
|
||||
'fill_rate' => $this->fill_rate,
|
||||
'effective_start_time' => $this->effective_start_time,
|
||||
'effective_end_time' => $this->effective_end_time,
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
'time_slot' => new TimeSlotResource($this->whenLoaded('timeSlot')),
|
||||
'location' => new LocationResource($this->whenLoaded('location')),
|
||||
'festival_section' => new FestivalSectionResource($this->whenLoaded('festivalSection')),
|
||||
];
|
||||
}
|
||||
|
||||
private function shouldShowCoordinatorNotes(Request $request): bool
|
||||
{
|
||||
$user = $request->user();
|
||||
if (! $user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($user->hasRole('super_admin')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$shift = $this->resource;
|
||||
$event = $shift->festivalSection?->event;
|
||||
if (! $event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $event->organisation->users()
|
||||
->where('user_id', $user->id)
|
||||
->wherePivot('role', 'org_admin')
|
||||
->exists()
|
||||
|| $event->users()
|
||||
->where('user_id', $user->id)
|
||||
->wherePivot('role', 'event_manager')
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user