Implements the complete ShiftAssignment lifecycle: - ShiftAssignmentStatus enum with allowed transitions - ShiftAssignmentService with claim/assign/approve/reject/cancel/bulkApprove - ShiftAssignmentController with event-scoped endpoints - ShiftAssignmentPolicy (organizer + volunteer self-cancel) - VolunteerAvailability model, controller, and sync endpoint - Refactored ShiftController to delegate to service layer - 31 workflow tests covering all paths and multi-tenancy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\Api\V1;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
final class ShiftAssignmentResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'shift_id' => $this->shift_id,
|
|
'person_id' => $this->person_id,
|
|
'time_slot_id' => $this->time_slot_id,
|
|
'status' => $this->status->value,
|
|
'auto_approved' => $this->auto_approved,
|
|
'assigned_by' => $this->assigned_by,
|
|
'assigned_at' => $this->assigned_at?->toIso8601String(),
|
|
'approved_by' => $this->approved_by,
|
|
'approved_at' => $this->approved_at?->toIso8601String(),
|
|
'rejection_reason' => $this->rejection_reason,
|
|
'hours_expected' => $this->hours_expected,
|
|
'hours_completed' => $this->hours_completed,
|
|
'checked_in_at' => $this->checked_in_at?->toIso8601String(),
|
|
'checked_out_at' => $this->checked_out_at?->toIso8601String(),
|
|
'is_cancellable' => $this->isCancellable(),
|
|
'is_approvable' => $this->isApprovable(),
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
|
|
'person' => new PersonResource($this->whenLoaded('person')),
|
|
'shift' => new ShiftResource($this->whenLoaded('shift')),
|
|
];
|
|
}
|
|
}
|