*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'data' => $this->data, 'ticket_id' => $this->ticket_id, 'ticket' => $this->ticket?->ticket, 'category' => $this->ticket?->sourceCatalogItem?->category?->nombre, 'attempted_at' => $this->created_at, 'resolved_at' => $this->resolved_at, 'result' => $this->result->value, 'result_label' => match ($this->result) { ScanAttemptResult::Accepted => 'Verificado', ScanAttemptResult::AlreadyScanned => 'Usado', ScanAttemptResult::Expired => 'Vencido', default => 'Error', }, 'result_detail_label' => match ($this->result) { ScanAttemptResult::Processing => 'Error', ScanAttemptResult::Accepted => 'Verificado', ScanAttemptResult::InvalidQr => 'QR no pertenece al evento', ScanAttemptResult::TicketNotFound => 'Error', ScanAttemptResult::CategoryForbidden => 'Error', ScanAttemptResult::AlreadyScanned => 'Usado', ScanAttemptResult::Expired => 'Vencido', ScanAttemptResult::NotValid => 'No vĂ¡lido', ScanAttemptResult::UnexpectedError => 'Error', }, 'can_view_ticket' => $this->ticket !== null && $this->result !== ScanAttemptResult::CategoryForbidden, ]; } }