コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $insert = PromotionAdvance::where('user_id', \Auth::user()->id)->where('type', $request->type_adv)->first();
     if ($insert) {
         $insert->prix = $request->prix_adv;
         $insert->type = intval($request->type_adv);
         $insert->active = 1;
         $insert->save();
     } else {
         $adv = new PromotionAdvance();
         $adv->type = intval($request->type_adv);
         $adv->prix = $request->prix_adv;
         $adv->user_id = \Auth::user()->id;
         $adv->active = 1;
         $adv->save();
     }
     $pro_adv = PromotionAdvance::where('user_id', \Auth::user()->id)->get();
     if (!$pro_adv->isEmpty()) {
         foreach ($pro_adv as $item) {
             $pv = PromotionAdvance::where('user_id', \Auth::user()->id)->where('id', $item->id)->first();
             $pv->active = 1;
             $pv->save();
         }
     }
     $pro_exc = PromotionExceptional::where('user_id', \Auth::user()->id)->first();
     if ($pro_exc) {
         $pro_exc->active = 0;
         $pro_exc->save();
     }
     return redirect()->back()->with('success', 'Bien Enregistrée');
 }
コード例 #2
0
 public static function checkExcPriceandReturnIt()
 {
     $pro_exc = PromotionExceptional::where('user_id', \Auth::user()->id)->where('active', 1)->first();
     if ($pro_exc) {
         if ($pro_exc->price && $pro_exc->price > 0) {
             return $pro_exc->price;
         } else {
             return 'no';
         }
     }
 }
コード例 #3
0
 public function getData()
 {
     if (\Request::ajax()) {
         $user_id = \Input::get('user_id');
         $checkPrice = PromotionExceptional::where('user_id', $user_id)->first();
         if ($checkPrice) {
             echo json_encode($checkPrice);
             die;
         } else {
             $tab = [];
             echo json_encode($tab);
             die;
         }
     }
 }
コード例 #4
0
 public function setbloc2()
 {
     if (\Request::ajax()) {
         $bloc2_status = \Input::get('bloc2status');
         $global_status = PromotionStatus::where('user_id', \Auth::user()->id)->first();
         if ($bloc2_status == 1) {
             $global_status->bloc1 = 0;
             $global_status->bloc2 = 1;
             $global_status->save();
             // adv
             $pro_adv = PromotionAdvance::where('user_id', \Auth::user()->id)->get();
             if (!$pro_adv->isEmpty()) {
                 foreach ($pro_adv as $item) {
                     $pv = PromotionAdvance::where('user_id', \Auth::user()->id)->where('id', $item->id)->first();
                     $pv->active = 0;
                     $pv->save();
                 }
             }
             // exc
             $pro_exc = PromotionExceptional::where('user_id', \Auth::user()->id)->first();
             if ($pro_exc) {
                 $pro_exc->active = 1;
                 $pro_exc->save();
             }
         } else {
             $global_status->bloc1 = 1;
             $global_status->bloc2 = 0;
             $global_status->save();
         }
     }
 }