示例#1
0
 public function account()
 {
     if (Auth::check()) {
         $query = User::select('referal_id', 'active')->where('referal_id', '=', Auth::id())->where('active', '=', '1');
         if ($query->count() == 0) {
             $total = $query->count();
         } else {
             $total = $query->count();
         }
         $ungrouped_total = User::where('referal_id', '=', Auth::id())->where('arrange_group', '=', 'ungrouped')->get();
         $left_count = User::where('referal_id', '=', Auth::id())->where('arrange_group', '=', 'left_side')->get();
         if ($left_count->count() == 0) {
             $left = $left_count->count();
         } else {
             $left = $left_count->count();
         }
         $right_count = User::where('referal_id', '=', Auth::id())->where('arrange_group', '=', 'right_side')->get();
         if ($right_count->count() == 0) {
             $right = $right_count->count();
         } else {
             $right = $right_count->count();
         }
         $points = Point::where("user_id", Auth::user()->id);
         if ($points->count() > 0) {
             $point = $points->sum("point") . " points";
         } else {
             $point = 0 . " point";
         }
         $amounts = Amount::where("user_id", Auth::user()->id);
         if ($amounts->count() > 0) {
             $amount = "৳ " . $amounts->sum("amount");
         } else {
             $amount = "৳ " . 0;
         }
         return View::make('Users.Account', array('total' => $total, 'left' => $left, 'right' => $right, 'ungrouped' => $ungrouped_total, 'left_member' => $left_count, 'right_member' => $right_count, 'point' => $point, 'amount' => $amount));
     } else {
         return Redirect::route("login")->with("event", "<p class='alert alert-danger'><span class='glyphicon glyphicon-exclamation-sign'></span> You are not logged in!</p>");
     }
 }
示例#2
0
 public function home()
 {
     $catagory = Catagory::all();
     $subcatagory = Subcatagory::all();
     $product = Product::orderBy('created_at', 'desc')->paginate(9);
     // Check if any users have got any amount by their referals
     if (Auth::user()) {
         $amount = Amount::where("user_id", Auth::user()->id)->where('status', 0);
         if ($amount->count() > 0) {
             $amount->update(['status' => 1]);
             // Check the user's referal is an admin or not
             $my_referal = User::find(Auth::user()->referal_id);
             if (Auth::user()->referal_id != 0) {
                 if ($my_referal->type == 'admin') {
                     $distributed_amount = 600;
                 } else {
                     $distributed_amount = 300;
                 }
                 Amount::create(['user_id' => Auth::user()->referal_id, 'amount' => $distributed_amount]);
             }
         }
     }
     return View::make('Main.Home.Index', array('catagories' => $catagory, 'subcatagories' => $subcatagory, 'products' => $product));
 }