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>
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\ShiftAssignmentStatus;
|
|
use App\Models\Person;
|
|
use App\Models\Shift;
|
|
use App\Models\ShiftAssignment;
|
|
use App\Models\TimeSlot;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/** @extends Factory<ShiftAssignment> */
|
|
final class ShiftAssignmentFactory extends Factory
|
|
{
|
|
/** @return array<string, mixed> */
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'shift_id' => Shift::factory(),
|
|
'person_id' => Person::factory(),
|
|
'time_slot_id' => TimeSlot::factory(),
|
|
'status' => ShiftAssignmentStatus::PENDING_APPROVAL,
|
|
'auto_approved' => false,
|
|
'assigned_at' => now(),
|
|
];
|
|
}
|
|
|
|
public function approved(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'status' => ShiftAssignmentStatus::APPROVED,
|
|
'approved_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function autoApproved(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'status' => ShiftAssignmentStatus::APPROVED,
|
|
'auto_approved' => true,
|
|
'approved_at' => now(),
|
|
]);
|
|
}
|
|
}
|