trucks (with optional last_known_coordinates POINT 4326), collection_teams, team_members. Admin CRUD for both. TeamConflictDetector flags double-assignment of driver/scanner/truck/helper across active teams; override_conflicts: true bypasses for emergencies. Promotes routes.default_team_id to a real FK now that collection_teams exists. 144 feature tests passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class CollectionTeamResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->uuid,
|
|
'name' => $this->name,
|
|
'status' => $this->status,
|
|
'area' => ServiceAreaResource::make($this->whenLoaded('area')),
|
|
'driver' => UserResource::make($this->whenLoaded('driver')),
|
|
'scanner' => UserResource::make($this->whenLoaded('scanner')),
|
|
'truck' => TruckResource::make($this->whenLoaded('truck')),
|
|
'helpers' => $this->whenLoaded('helpers', fn () => $this->helpers->map(fn ($m) => [
|
|
'id' => $m->user?->uuid,
|
|
'name' => $m->user?->full_name,
|
|
'assigned_from' => $m->assigned_from?->toDateString(),
|
|
'assigned_until' => $m->assigned_until?->toDateString(),
|
|
])),
|
|
'notes' => $this->notes,
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|