public function getIndex()
 {
     $title = 'public';
     // get 8 most popular online rewards
     $rewards = Reward::orderBy('claimed', 'desc')->take(8)->get();
     // get last 5 winners
     $winners = Winner::orderBy('created_at', 'desc')->take(5)->get();
     // check if competition is running, has yet to start or has ended
     $time = Carbon::now()->toDateTimeString();
     $runningPeriod = Period::where('running', 1)->get();
     $firstPeriod = Period::orderBy('id', 'asc')->first();
     if (count($runningPeriod) == 1) {
         $competition['running'] = true;
         $competition['message'] = 'Enter your codes here to get your well-deserved points';
     } else {
         $competition['running'] = false;
         if ($time < $firstPeriod->start) {
             $competition['message'] = 'The competition has yet to start';
         } else {
             $competition['message'] = 'The competition has ended';
         }
     }
     // if logged in go to dashboard
     if (Auth::check()) {
         $user = Auth::user();
         $username = $user->name;
         $userPoints = $user->points;
         $title = 'Dashboard';
         $rewards = Reward::all();
         return view('dashboard.home', compact('competition', 'title', 'username', 'rewards', 'userPoints'));
     }
     return view('public.home', compact('competition', 'title', 'rewards', 'winners'));
 }
示例#2
0
 public function offer(Request $request)
 {
     $order_user_id = null;
     $v = Validator::make($request->all(), ['project_id' => 'required|numeric']);
     if ($v->fails()) {
         //            return redirect('post/create')
         //                        ->withErrors($validator)
         //                        ->withInput();
     }
     if ($request->has('fullname') && $request->has('email') && $request->has('phone') && empty($this->user->id)) {
         /*
          *  хэрэв fullname, email, phone 3 орж ирвэл хэрэглэгч шинээр бүртгэнэ
          */
         $user = new User();
         $user->fullname = $request->get('fullname');
         $user->email = $request->get('email');
         $user->phone = $request->get('phone');
         $user->register_ip = $_SERVER['REMOTE_ADDR'];
         $user->registered_with = 'local';
         $user->public = 0;
         $user->status = 1;
         $user->role = 2;
         $user->save();
         $order_user_id = $user->id;
         //user controller-оос авч хэрэглэх /яаж??/
         //$this->sendThankYouEmail($user);
     } else {
         /*
          *  хэрэглэгч нэвтэрсэн гэж ойлгоно
          */
         $order_user_id = $this->user->id;
     }
     $payment = new Payment();
     if ($request->has('reward_id') && $request->has('reward_qty')) {
         /*
          *  хэрэв reward_id, reward_qty 2 орж ирвэл reward авч байна гэж ойлно
          */
         $reward = Reward::find($request->get('reward_id'));
         $payment->reward_id = $reward->id;
         $payment->value = $reward * $request->get('reward_qty');
         $payment->gateway = 'reward';
     } else {
         /*
          *  хэрэв donation орж ирвэл хандив өгч байна гэж ойлно
          */
         $payment->value = $request->get('donation');
         $payment->gateway = 'donation';
     }
     $payment->project_id = $request->get('project_id');
     $payment->user_id = $order_user_id;
     $payment->note = $request->get('note');
     $payment->save();
     $result = $this->process_payment($payment);
     if (!$result) {
         //харгалзах view дуудах
     }
 }
 public function run()
 {
     DB::table('rewards')->delete();
     Reward::create(['name' => 'Amazon Gift Card', 'description' => 'This is a gift card for Amazon', 'value' => 100, 'filename' => '51672-detail.jpg']);
     Reward::create(['name' => 'Walmart Gift Card', 'description' => 'Use this gift card in your local Walmart', 'value' => 200, 'filename' => '2Xe1S.png']);
     Reward::create(['name' => 'Nike Gift Card', 'description' => 'A gift card for Nike. Usable in your local Nike retailer', 'value' => 300, 'filename' => 'DRHk1.png']);
     Reward::create(['name' => 'Google Play Credits', 'description' => 'Get credits for your Google Play accounts', 'value' => 100, 'filename' => '53219-detail.png']);
     Reward::create(['name' => 'Personalized Bottles', 'description' => 'Get 4 personalized bottles of your favorite Coca Cola drinks', 'value' => 200, 'filename' => 'MRU30.png']);
     Reward::create(['name' => 'Olive Garden Gift Card', 'description' => 'A gift card for Olive Garden', 'value' => 300, 'filename' => 'MY3Yo.png']);
     Reward::create(['name' => 'Spotify Credits', 'description' => 'Free credits for your Spotify Account', 'value' => 100, 'filename' => '29608-detail.png']);
     Reward::create(['name' => 'AMC credits', 'description' => 'Get credits for AMC', 'value' => 200, 'filename' => 'rougZ.png']);
     Reward::create(['name' => 'GroupOn Gift Card', 'description' => 'Get a giftcard for GroupOn', 'value' => 200, 'filename' => '52588-detail.png']);
     Reward::create(['name' => 'GameStop credits', 'description' => 'Get credits for GameStop', 'value' => 200, 'filename' => '28228-detail.png']);
 }
 public function getRegister()
 {
     $rewards = Reward::orderBy('claimed', 'desc')->take(8)->get();
     if (Auth::check()) {
         return view('dashboard.home');
     }
     $code = WinningCode::where('bonus', 1)->first()->code;
     return view('auth.register', compact('code', 'rewards'));
 }
 public function postUnlock(Request $request)
 {
     $title = 'Dashboard unlock reward';
     $rewardId = $request->id;
     // get reward for detail page
     $reward = Reward::find($rewardId);
     // get 8 most popular rewards
     $rewards = Reward::orderBy('claimed', 'desc')->take(8)->get();
     $user = Auth::user();
     $username = $user->name;
     $userPoints = $user->points;
     $message = '';
     // check if user has enough points
     if ($userPoints >= $reward->value) {
         // calculate new points
         $user->points = $userPoints - $reward->value;
         $userPoints = $user->points;
         // add reward to rewards of user
         $user->rewards()->attach($rewardId);
         $reward->claimed = $reward->claimed + 1;
         $reward->save();
         $user->save();
         $message = 'Congratulations! You bought it!';
         return view('dashboard.reward.unlock', compact('title', 'username', 'reward', 'userPoints', 'rewards', 'message'));
     } else {
         // not enough points to unlock
         $message = 'You dont have enough points!';
         return view('dashboard.reward.unlock', compact('title', 'username', 'reward', 'userPoints', 'rewards', 'message'));
     }
 }
 public function restoreReward($id)
 {
     if (Auth::user()->admin) {
         $title = 'admin rewards';
         // search for reward
         $reward = Reward::withTrashed()->where('id', $id)->get()->first();
         $reward->restore();
         // get all online rewards
         $rewards = Reward::orderBy('created_at', 'desc')->get();
         // get all deleted rewards
         $deletedRewards = Reward::onlyTrashed()->get();
         return view('admin.rewards', compact('title', 'rewards', 'deletedRewards'));
     } else {
         return redirect('dashboard');
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Reward::destroy($id);
     $set = Set::find(1);
     $rewards = Reward::with('media')->where('set_id', $set->id)->orderby('blocks', 'desc')->get();
     return view('admin.rewards.index', ['set' => $set, 'rewards' => $rewards]);
 }
示例#8
0
 public function donateModal(Request $request)
 {
     $col = 6;
     if ($this->user) {
         $col = 12;
     }
     $projectid = $request->get('projectid');
     $project = Reward::find($projectid);
     $donateModal = view('modules.modal', ['id' => 'donatemodal' . $projectid, 'title' => trans('project.donate'), 'modalbody' => 'modules.project.donate'])->withUser($this->user)->withCol($col)->withProject($project)->render();
     $return['status'] = true;
     $return['view'] = $donateModal;
     return $return;
 }