HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/laravel/app/Models/ApiLog.php
<?php

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class ApiLog extends Model
{
    public $timestamps = false;

    protected $table = 'api_logs';

    protected $fillable = [
        'user_id',
        'request',
        'response',
        'created_at',
    ];

    public function createLog($request, $response, $userId = 0)
    {
        $dt = new Carbon();
        $dt->setTimezone('UTC');
        $headers  = $request->header();
        $data = [
            'path'         => $request->getPathInfo(),
            'token'        => $request->token,
            'json'        => $request->json,
            'method'       => $request->getMethod(),
            'ip'           => $request->ip(),
            'http_version' => $_SERVER['SERVER_PROTOCOL'] ?? '',
            'timestamp'    => $dt->toDateTimeString(),
            'headers'      => $headers,

        ];

        $this->user_id = $userId;
        $this->request = json_encode($data);
        $this->response = substr(json_encode($response), 0, 2000);
        $this->created_at = $dt->toDateTimeString();
        $this->save();

    }
}