Update SeasonalController

This commit is contained in:
Daniel Supernault 2021-01-30 19:56:10 -07:00
parent 2281727ac0
commit 090b6d0336
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -219,20 +219,21 @@ class SeasonalController extends Controller
{ {
abort_if(now()->gt('2021-03-01 00:00:00'), 404); abort_if(now()->gt('2021-03-01 00:00:00'), 404);
abort_if(config('database.default') != 'mysql', 404); abort_if(config('database.default') != 'mysql', 404);
$this->validate($request, [
'profile_id' => 'required',
'type' => 'required|string|in:view,hide'
]);
$user = $request->user(); $user = $request->user();
$log = new AccountLog(); $log = AccountLog::firstOrCreate([
$log->user_id = $user->id; [
$log->item_type = 'App\User'; 'item_type' => 'App\User',
$log->item_id = $user->id; 'item_id' => $user->id,
$log->action = $request->input('type') == 'view' ? 'seasonal.my2020.view' : 'seasonal.my2020.hide'; 'user_id' => $user->id,
$log->ip_address = $request->ip(); 'action' => 'seasonal.my2020.view'
$log->user_agent = $request->user_agent(); ],
$log->save(); [
'ip_address' => $request->ip(),
'user_agent' => $request->userAgent()
]
]);
return response()->json(200);
} }
} }