From 5d0a1ebb7a928dd77dd64c9dba4a7ad8c7723e6f Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 7 Apr 2022 11:08:43 -0700 Subject: [PATCH] fixes action_date for check-in not including H:i:s --- app/Http/Controllers/Assets/AssetCheckinController.php | 7 ++++--- app/Models/Loggable.php | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index e1a30b30cc..ea7313ad06 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -106,11 +106,12 @@ class AssetCheckinController extends Controller $asset->location_id = e($request->get('location_id')); } - $checkin_at = date('Y-m-d'); - if ($request->filled('checkin_at')) { - $checkin_at = $request->input('checkin_at'); + $checkin_at = date('Y-m-d H:i:s'); + if (($request->filled('checkin_at')) && ($request->get('checkin_at') != date('Y-m-d'))) { + $checkin_at = $request->get('checkout_at'); } + if(!empty($asset->licenseseats->all())){ foreach ($asset->licenseseats as $seat){ $seat->assigned_to = null; diff --git a/app/Models/Loggable.php b/app/Models/Loggable.php index 3609298ac7..fe3a407288 100644 --- a/app/Models/Loggable.php +++ b/app/Models/Loggable.php @@ -4,6 +4,7 @@ namespace App\Models; use App\Models\Setting; use App\Notifications\AuditNotification; +use Carbon\Carbon; use Illuminate\Support\Facades\Auth; trait Loggable @@ -115,6 +116,10 @@ trait Loggable $log->note = $note; $log->action_date = $action_date; + if (! $log->action_date) { + $log->action_date = date('Y-m-d H:i:s'); + } + if (Auth::user()) { $log->user_id = Auth::user()->id; }