feat(scanner): return scan attempt result context
This commit is contained in:
@@ -98,7 +98,7 @@ class ScannerTicketService
|
||||
return $query->firstOrFail();
|
||||
}
|
||||
|
||||
public function scan(User $scanner, mixed $scannedData): Ticket
|
||||
public function scan(User $scanner, mixed $scannedData): ScanAttempt
|
||||
{
|
||||
$scanAttempt = ScanAttempt::query()->create([
|
||||
'tenant_code' => $scanner->tenant_codigo,
|
||||
@@ -125,7 +125,7 @@ class ScannerTicketService
|
||||
$scanAttempt,
|
||||
&$ticketId,
|
||||
&$failureResult,
|
||||
): Ticket {
|
||||
): ScanAttempt {
|
||||
$ticket = $this->baseQuery()
|
||||
->where('tenant_code', $scanner->tenant_codigo)
|
||||
->where('ticket', $scannedData)
|
||||
@@ -172,7 +172,9 @@ class ScannerTicketService
|
||||
$ticketId,
|
||||
);
|
||||
|
||||
return $ticket->refresh()->load($this->relations());
|
||||
$ticket = $ticket->refresh()->load($this->relations());
|
||||
|
||||
return $scanAttempt->refresh()->setRelation('ticket', $ticket);
|
||||
});
|
||||
} catch (Throwable $exception) {
|
||||
$result = $exception instanceof ModelNotFoundException
|
||||
|
||||
Reference in New Issue
Block a user