From d6780908ce03e6cc456d094405e7d5985308df5d Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Mon, 7 Aug 2023 21:50:42 +0100 Subject: [PATCH 1/2] Refactor Reservations_model::getNextBookableTable() to only retrieve confirmed reservations. Signed-off-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/models/Reservations_model.php | 2 +- app/system/language/en/lang.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/models/Reservations_model.php b/app/admin/models/Reservations_model.php index bcd78eeac6..7e482e5838 100644 --- a/app/admin/models/Reservations_model.php +++ b/app/admin/models/Reservations_model.php @@ -308,7 +308,7 @@ public static function findReservedTables($location, $dateTime) }); $query->whereLocationId($location->getKey()); $query->whereBetweenDate($dateTime->toDateTimeString()); - $query->whereNotIn('status_id', [0, setting('canceled_reservation_status')]); + $query->where('status_id', setting('confirmed_reservation_status')); $result = $query->get(); return $result->pluck('tables')->flatten()->keyBy('table_id'); diff --git a/app/system/language/en/lang.php b/app/system/language/en/lang.php index b4eb978c0d..8cf9ac067f 100644 --- a/app/system/language/en/lang.php +++ b/app/system/language/en/lang.php @@ -524,7 +524,7 @@ 'help_invoice_prefix' => 'Set the invoice prefix (e.g. INV-2015-001123). Leave blank to use no prefix. The following macros are available: {year} {month} {day} {hour} {minute} {second}', 'help_default_reservation_status' => 'Select the default reservation status when new reservation received', 'help_canceled_reservation_status' => 'Select the reservation status when a reservation is marked as canceled or suspected of fraudulent activity', - 'help_confirmed_reservation_status' => 'Select the reservation status to mark a reservation as confirmed before table is reserved', + 'help_confirmed_reservation_status' => 'Select the reservation status when a reservation is confirmed and table marked as reserved', 'help_delete_thumbs' => 'This will delete all created thumbs. Note thumbs are automatically created.', 'help_media_max_size' => 'The maximum size (in kilobytes) limit for file when uploading.', 'help_media_extensions' => 'The allowed file extensions for uploaded files. Multiple extensions can be separated by commas.', From cf3403c65460308615de0e437598c24293609c97 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Tue, 15 Aug 2023 18:49:25 +0100 Subject: [PATCH 2/2] Refactor LogUserLastSeen.php to support multiple authentication services and update last seen time for each authenticated user. Signed-off-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- ...properties_on_user_preferences_table.php.php | 2 +- app/admin/middleware/LogUserLastSeen.php | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/admin/database/migrations/2023_06_06_000400_update_dashboard_widget_properties_on_user_preferences_table.php.php b/app/admin/database/migrations/2023_06_06_000400_update_dashboard_widget_properties_on_user_preferences_table.php.php index 5aa44b3721..483e999103 100644 --- a/app/admin/database/migrations/2023_06_06_000400_update_dashboard_widget_properties_on_user_preferences_table.php.php +++ b/app/admin/database/migrations/2023_06_06_000400_update_dashboard_widget_properties_on_user_preferences_table.php.php @@ -29,7 +29,7 @@ public function up() ->value('value'); $widgets = collect(json_decode($widgets, true))->mapWithKeys(function ($properties, $alias) { - if ($options = array_get($this->widgetsMap, array_pull($properties, 'class'))) { + if ($options = array_get($this->widgetsMap, array_pull($properties, 'class', ''))) { $properties['widget'] = $options[0]; $props = array_pull($properties, 'config'); diff --git a/app/admin/middleware/LogUserLastSeen.php b/app/admin/middleware/LogUserLastSeen.php index 7cefc77f53..f1faf3117c 100644 --- a/app/admin/middleware/LogUserLastSeen.php +++ b/app/admin/middleware/LogUserLastSeen.php @@ -2,7 +2,6 @@ namespace Admin\Middleware; -use Admin\Facades\AdminAuth; use Carbon\Carbon; use Closure; use Illuminate\Support\Facades\App; @@ -12,12 +11,16 @@ class LogUserLastSeen { public function handle($request, Closure $next) { - if (App::hasDatabase() && AdminAuth::check()) { - $cacheKey = 'is-online-user-'.AdminAuth::getId(); - $expireAt = Carbon::now()->addMinutes(2); - Cache::remember($cacheKey, $expireAt, function () { - return AdminAuth::user()->updateLastSeen(Carbon::now()->addMinutes(5)); - }); + if (App::hasDatabase()) { + foreach (['admin.auth', 'auth'] as $authService) { + if (App::hasDatabase() && resolve($authService)->check()) { + $cacheKey = 'is-online-'.str_replace('.', '-', $authService).'-user-'.resolve($authService)->getId(); + $expireAt = Carbon::now()->addMinutes(2); + Cache::remember($cacheKey, $expireAt, function () use ($authService) { + return resolve($authService)->user()->updateLastSeen(Carbon::now()); + }); + } + } } return $next($request);