Files
kulakpos_web/public/restaurant/app/Traits/Trackable.php

37 lines
972 B
PHP
Raw Normal View History

2026-03-15 17:08:23 +07:00
<?php
namespace App\Traits;
use Modules\Authentication\Models\UserLog;
trait Trackable
{
public function trackAction($action = 'create', $model = null, $model_id = null, $detail = null): void
{
try {
if (! auth()->check()) {
return;
}
$user = auth()->user();
$user_id = $user->id;
$ip_address = request()->ip();
$url = request()->fullUrl();
$userLog = new UserLog;
$userLog->user_id = $user_id;
$userLog->institute_id = getUserRestaurantId();
$userLog->user_id = $user_id;
$userLog->ip_address = $ip_address;
$userLog->action = $action;
$userLog->detail = $detail;
$userLog->model = $model;
$userLog->url = $url;
$userLog->model_id = $model_id;
$userLog->save();
} catch (\Throwable $th) {
//
}
}
}