예제 #1
0
 public function postCheck(Request $request, VoteSite $site)
 {
     if (!VoteLog::recent($request, $site)->exists()) {
         $user = UserInfo::find(Auth::user()->username);
         $user->pvalues = $site->double_rewards ? $site->reward_amount * 2 : $site->reward_amount + $user->pvalues;
         $user->save();
         VoteLog::create(['user_id' => Auth::user()->id, 'ip_address' => $request->ip(), 'reward' => $site->double_rewards ? $site->reward_amount * 2 : $site->reward_amount, 'site_id' => $site->id]);
         return redirect('vote/success/' . $site->id);
     } else {
         flash()->error(trans('vote.already_voted'));
         return redirect()->back();
     }
 }
예제 #2
0
 public function postCheck(Request $request, VoteSite $site)
 {
     if (!VoteLog::recent($request, $site)->exists()) {
         switch ($site->type) {
             case 'virtual':
                 $user = Auth::user();
                 $user->money = $site->double_rewards ? $site->reward_amount * 2 : $site->reward_amount + $user->money;
                 $user->save();
                 break;
             case 'cubi':
                 Transfer::create(['user_id' => Auth::user()->ID, 'zone_id' => 1, 'cash' => $site->double_rewards ? $site->reward_amount * 2 : $site->reward_amount]);
                 break;
         }
         VoteLog::create(['user_id' => Auth::user()->ID, 'ip_address' => $request->ip(), 'reward' => $site->double_rewards ? $site->reward_amount * 2 : $site->reward_amount, 'site_id' => $site->id]);
         return redirect('vote/success/' . $site->id);
     } else {
         flash()->error(trans('vote.already_voted'));
         return redirect()->back();
     }
 }