public function existed($pointable_type, $pointable_id, $issue_id)
 {
     $countMe = Point::where('pointable_type', '=', $pointable_type)->where('pointable_id', '=', $pointable_id)->where('issue_id', '=', $issue_id)->count();
     if ($countMe > 0) {
         return true;
     } else {
         return false;
     }
 }
 private function add_daily_comment_points()
 {
     $user_id = Auth::user()->id;
     $LastCommentPoints = Point::where('user_id', '=', $user_id)->where('description', '=', Lang::get('lang.daily_comment'))->orderBy('created_at', 'desc')->take(5)->get();
     $total_daily_comments = 0;
     foreach ($LastCommentPoints as $CommentPoint) {
         if (date('Ymd') == date('Ymd', strtotime($CommentPoint->created_at))) {
             $total_daily_comments += 1;
         }
     }
     if ($total_daily_comments < 5) {
         $point = new Point();
         $point->user_id = $user_id;
         $point->description = Lang::get('lang.daily_comment');
         $point->points = 1;
         $point->save();
         return true;
     } else {
         return false;
     }
 }
Exemple #3
0
 public function points($username)
 {
     $user = User::where('username', '=', $username)->first();
     if (!Auth::guest() && Auth::user()->id == $user->id) {
         $is_user_profile = true;
     }
     $user_points = DB::table('points')->where('user_id', '=', $user->id)->sum('points');
     $data = array('user' => $user, 'points' => Point::where('user_id', '=', $user->id)->get(), 'settings' => Setting::first(), 'is_user_profile' => $is_user_profile, 'user_points' => $user_points);
     return View::make('Theme::user', $data);
 }
 public function recharge()
 {
     $v = Validator::make(Input::all(), ["code" => "required|size:22"], ["required" => "<span class='glyphicon glyphicon-exclamation-sign'></span> Please typr the code.", "size" => "<span class='glyphicon glyphicon-exclamation-sign'></span> Invalid code"]);
     if ($v->fails()) {
         return Redirect::back()->withErrors($v)->withInput();
     }
     $find = Product::where("code", Input::get("code"));
     if ($find->count() > 0) {
         // Give the point associated with the code
         $point = $find->get()->first()->point;
         $p = new Point();
         $p->user_id = Auth::user()->id;
         $p->point = $point;
         $p->product_id = $find->get()->first()->id;
         $p->save();
         // Set user's designation
         $active_member = User::find(Auth::user()->id);
         $active_member->designation = "Active member";
         $active_member->save();
         // Remove the code from product. So that any user can't use the same code twice.
         $find->update(["code" => ""]);
         // If the user has 1000 points then add amount 500
         $how_many_points = Point::where('user_id', Auth::user()->id)->sum('point');
         if ($how_many_points >= 1000) {
             // Set the user's designation to Model member
             $model_member = User::find(Auth::user()->id);
             $model_member->designation = "Model member";
             $model_member->save();
             // Check the user's referal is an admin or not
             $my_referal = User::find(Auth::user()->referal_id);
             if ($my_referal->type == 'admin') {
                 $distributed_amount = 600;
             } else {
                 $distributed_amount = 300;
             }
             Amount::create(['user_id' => Auth::user()->id, 'amount' => 500, 'status' => 1]);
             Amount::create(['user_id' => Auth::user()->referal_id, 'amount' => $distributed_amount]);
             Point::where('user_id', Auth::user()->id)->delete();
         }
         return Redirect::back()->with("event", "<p class='alert alert-success'><span class='glyphicon glyphicon-ok'></span> Congratulation! You got " . $point . " points.</p>");
     }
     return Redirect::back()->with("event", "<p class='alert alert-danger'><span class='glyphicon glyphicon-exclamation-sign'></span> Invalid code.</p>");
 }
Exemple #5
0
 public function points($username)
 {
     $user = User::where('username', '=', $username)->first();
     $data = array('user' => $user, 'points' => Point::where('user_id', '=', $user->id)->get());
     return View::make('user.points', $data);
 }
 private function getHighest($event)
 {
     $highest = Point::where('pointable_type', '=', 'Activity')->where('pointable_id', '=', $event)->max('point');
     return $highest;
 }