authorize('create', Vote::class); $vote = Vote::create([ 'userID' => Auth::user()->id, 'allowedVoteType' => $voteRequest->voteType, ]); $vote->application()->attach($applicationID); Log::info('User ' . Auth::user()->name . ' has voted in applicant ' . $application->user->name . '\'s application', [ 'voteType' => $voteRequest->voteType ]); $voteRequest->session()->flash('success', 'Your vote has been registered!'); // Cron job will run command that processes votes return redirect()->back(); } }