29 lines
870 B
PHP
29 lines
870 B
PHP
<?php
|
|
|
|
namespace App\Domains\Ticket\Resources\Scanner;
|
|
|
|
use App\Domains\Ticket\Enums\ScanAttemptResult;
|
|
use App\Domains\Ticket\Models\ScanAttempt;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/** @mixin ScanAttempt */
|
|
class ScanAttemptResource extends JsonResource
|
|
{
|
|
/** @return array<string, mixed> */
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'data' => $this->data,
|
|
'ticket_id' => $this->ticket_id,
|
|
'ticket' => $this->ticket?->ticket,
|
|
'attempted_at' => $this->created_at,
|
|
'resolved_at' => $this->resolved_at,
|
|
'result' => $this->result->value,
|
|
'can_view_ticket' => $this->ticket !== null
|
|
&& $this->result !== ScanAttemptResult::CategoryForbidden,
|
|
];
|
|
}
|
|
}
|