Implement household, QR sale, team helpers assignment, and helper endpoints

This commit is contained in:
Developer
2026-06-29 16:56:33 +08:00
parent b85fc255cf
commit 7dc074e3c3
31 changed files with 1574 additions and 98 deletions

View File

@@ -15,6 +15,33 @@ class ScannerController extends ApiController
{
public function __construct(private readonly ScanService $scanner) {}
public function teamDetails(Request $request): JsonResponse
{
$user = $request->user();
$team = \App\Models\CollectionTeam::query()
->with(['driver', 'truck', 'helpers.user'])
->where('scanner_id', $user->id)
->where('status', \App\Models\CollectionTeam::STATUS_ACTIVE)
->first();
if (! $team) {
return $this->fail('No active collection team assigned to this scanner', null, 404);
}
$trip = \App\Models\Trip::query()
->with(['route.stops.dropOffPoint', 'stops.dropOffPoint'])
->where('team_id', $team->id)
->whereIn('status', [\App\Models\Trip::STATUS_SCHEDULED, \App\Models\Trip::STATUS_IN_PROGRESS, \App\Models\Trip::STATUS_AT_DUMPSITE])
->orderBy('scheduled_date')
->first();
return $this->ok([
'team' => \App\Http\Resources\CollectionTeamResource::make($team),
'active_trip' => $trip ? \App\Http\Resources\TripResource::make($trip) : null,
]);
}
public function scan(Request $request): JsonResponse
{
$data = $request->validate([