File: /var/www/ipsremont-demo/app/Repository/Service/ServiceLastActionRepository.php
<?php
namespace App\Repository\Service;
use App\Helpers\UserHelper;
use App\Models\Service\ServiceListAction;
use Carbon\Carbon;
class ServiceLastActionRepository
{
public static function add(string $action): void
{
$user = UserHelper::getUser();
if (is_null($user) || !$user->isService()) {
return;
}
$service = $user->service;
$serviceListAction = new ServiceListAction();
$serviceListAction->service_id = $service->id;
$serviceListAction->action = $action;
$serviceListAction->save();
$service->last_action_at = Carbon::now();
$service->save();
}
}