From 090b6d033626438fd1748620909e986743460326 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 30 Jan 2021 19:56:10 -0700 Subject: [PATCH] Update SeasonalController --- app/Http/Controllers/SeasonalController.php | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/SeasonalController.php b/app/Http/Controllers/SeasonalController.php index d1077276d..a9f1f98cb 100644 --- a/app/Http/Controllers/SeasonalController.php +++ b/app/Http/Controllers/SeasonalController.php @@ -219,20 +219,21 @@ class SeasonalController extends Controller { abort_if(now()->gt('2021-03-01 00:00:00'), 404); abort_if(config('database.default') != 'mysql', 404); - $this->validate($request, [ - 'profile_id' => 'required', - 'type' => 'required|string|in:view,hide' - ]); $user = $request->user(); - $log = new AccountLog(); - $log->user_id = $user->id; - $log->item_type = 'App\User'; - $log->item_id = $user->id; - $log->action = $request->input('type') == 'view' ? 'seasonal.my2020.view' : 'seasonal.my2020.hide'; - $log->ip_address = $request->ip(); - $log->user_agent = $request->user_agent(); - $log->save(); + $log = AccountLog::firstOrCreate([ + [ + 'item_type' => 'App\User', + 'item_id' => $user->id, + 'user_id' => $user->id, + 'action' => 'seasonal.my2020.view' + ], + [ + 'ip_address' => $request->ip(), + 'user_agent' => $request->userAgent() + ] + ]); + return response()->json(200); } }