style: fix linting issues with Laravel Pint
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
namespace App\Http\Controllers\Api\V1\Scanner;
|
||||
|
||||
use App\Http\Controllers\Api\V1\ApiController;
|
||||
use App\Http\Resources\CollectionTeamResource;
|
||||
use App\Http\Resources\TripResource;
|
||||
use App\Models\CollectionTeam;
|
||||
use App\Models\DropOffPoint;
|
||||
use App\Models\Trip;
|
||||
use App\Models\TripStop;
|
||||
@@ -10,6 +13,7 @@ use App\Services\Scan\ScanService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ScannerController extends ApiController
|
||||
{
|
||||
@@ -19,32 +23,32 @@ class ScannerController extends ApiController
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
$team = \App\Models\CollectionTeam::query()
|
||||
$team = CollectionTeam::query()
|
||||
->with(['driver', 'truck', 'helpers.user'])
|
||||
->where('scanner_id', $user->id)
|
||||
->where('status', \App\Models\CollectionTeam::STATUS_ACTIVE)
|
||||
->where('status', CollectionTeam::STATUS_ACTIVE)
|
||||
->first();
|
||||
|
||||
if (! $team) {
|
||||
return $this->fail('No active collection team assigned to this scanner', null, 404);
|
||||
}
|
||||
|
||||
$trip = \App\Models\Trip::query()
|
||||
$trip = 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])
|
||||
->whereIn('status', [Trip::STATUS_SCHEDULED, Trip::STATUS_IN_PROGRESS, 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,
|
||||
'team' => CollectionTeamResource::make($team),
|
||||
'active_trip' => $trip ? TripResource::make($trip) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function scan(Request $request): JsonResponse
|
||||
{
|
||||
\Illuminate\Support\Facades\Log::info("DEBUG: Entering ScannerController::scan");
|
||||
Log::info('DEBUG: Entering ScannerController::scan');
|
||||
$data = $request->validate([
|
||||
'serial' => ['required', 'string', 'max:64'],
|
||||
'drop_off_point_id' => ['required', 'integer', 'exists:drop_off_points,id'],
|
||||
@@ -62,7 +66,7 @@ class ScannerController extends ApiController
|
||||
$dop = DropOffPoint::findOrFail($data['drop_off_point_id']);
|
||||
$trip = isset($data['trip_id']) ? Trip::where('uuid', $data['trip_id'])->first() : null;
|
||||
$stop = isset($data['trip_stop_id']) ? TripStop::find($data['trip_stop_id']) : null;
|
||||
\Illuminate\Support\Facades\Log::info("Scan attempt", ['serial' => $data['serial'] ?? 'none']);
|
||||
Log::info('Scan attempt', ['serial' => $data['serial'] ?? 'none']);
|
||||
|
||||
try {
|
||||
$result = $this->scanner->scan(
|
||||
@@ -80,14 +84,15 @@ class ScannerController extends ApiController
|
||||
scannedAt: isset($data['scanned_at']) ? Carbon::parse($data['scanned_at']) : null,
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::error("DEBUG: Scan Exception: " . $e->getMessage() . "\n" . $e->getTraceAsString());
|
||||
Log::error('DEBUG: Scan Exception: '.$e->getMessage()."\n".$e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
\Illuminate\Support\Facades\Log::info("DEBUG: Scan completed", ['accepted' => $result->accepted, 'reason' => $result->rejectReason ?? 'none']);
|
||||
Log::info('DEBUG: Scan completed', ['accepted' => $result->accepted, 'reason' => $result->rejectReason ?? 'none']);
|
||||
|
||||
if (! $result->accepted) {
|
||||
\Illuminate\Support\Facades\Log::warning("Scan rejected internally", ['serial' => $data['serial'], 'reason' => $result->rejectReason]);
|
||||
Log::warning('Scan rejected internally', ['serial' => $data['serial'], 'reason' => $result->rejectReason]);
|
||||
|
||||
return $this->fail(
|
||||
'Scan rejected',
|
||||
['reason' => [$result->rejectReason]],
|
||||
@@ -100,7 +105,7 @@ class ScannerController extends ApiController
|
||||
'log_id' => $result->log->id,
|
||||
'status' => (string) $result->code->status,
|
||||
];
|
||||
\Illuminate\Support\Facades\Log::info("Scan Response OK", $res);
|
||||
Log::info('Scan Response OK', $res);
|
||||
|
||||
return $this->ok($res, 'Scan recorded');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user