complete Complete User Request Submission section RAD-1
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Admin;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SessionsIndexResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'ip' => $this->ip_address,
|
||||
'user_agent' => $this->user_agent,
|
||||
"last_activity" => $this->generateLastTime(),
|
||||
];
|
||||
}
|
||||
|
||||
private function generateLastTime()
|
||||
{
|
||||
$timestamp = $this->last_activity;
|
||||
|
||||
$carbon = Carbon::createFromTimestamp($timestamp);
|
||||
return verta($carbon)->format('%Y/%m/%d - H:i');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user