27 lines
864 B
PHP
27 lines
864 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Security;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class IpBanResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
$blockedUntil = $this->resource->blocked_until ?? null;
|
|
$isActive = $blockedUntil !== null && $blockedUntil > now('UTC');
|
|
|
|
return [
|
|
'id' => $this->resource->id ?? null,
|
|
'ip_address' => $this->resource->ip_address ?? null,
|
|
'attempts' => $this->resource->attempts ?? 0,
|
|
'last_attempt_at' => $this->resource->last_attempt_at ?? null,
|
|
'blocked_until' => $blockedUntil,
|
|
'is_active' => $isActive,
|
|
'created_at' => $this->resource->created_at ?? null,
|
|
'updated_at' => $this->resource->updated_at ?? null,
|
|
];
|
|
}
|
|
}
|