예제 #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $today = date('Y-m-d');
     $promotion = Promotion::with('Product', 'Shop')->find($id);
     $samepromo = Promotion::with('Shop')->where('product_id', '=', $promotion->product_id)->where('id', '!=', $id)->where('start', '<=', $today)->where('end', '>=', $today)->get();
     return view('promotion.show', compact('promotion', 'samepromo'));
 }
 /**
  * Retourne tableau des promotions
  * Chaque promotion possède un tableau de ses specialitees
  */
 public function promotionWithSpecialiteArray()
 {
     $promotions = Promotion::with('specialites')->get();
     $result = [];
     foreach ($promotions as $promotion) {
         array_push($result, $promotion->specialites->lists('nom', 'id'));
     }
     return $result;
 }
예제 #3
0
 public function listPromotion($shopId = null, $categoryId = null)
 {
     $today = date('Y-m-d');
     $promotions = Promotion::with(['Product.Photo' => function ($query) {
         return $query->where('dimension', '=', '400x700')->get();
     }])->with('Shop')->where('start', '<=', $today)->where('end', '>=', $today);
     //filter by category
     if (isset($categoryId)) {
         $promotions->whereHas('product', function ($query) use($categoryId) {
             $query->where('category_id', '=', $categoryId);
         });
     }
     //filter by shop
     if (isset($shopId)) {
         $promotions->where('shop_id', '=', $shopId);
     }
     return $promotions = $promotions->paginate(20);
 }
 /**
  * Affiche le profil étudiant
  *
  * @return View
  */
 public function getEtudiantProfil()
 {
     $array['etudiant'] = Auth::user()->user;
     $array['promotions'] = Promotion::with('specialites')->get()->toJson();
     //Si aucune promotion n'est liée à l'étudiant
     if (isset($array['etudiant']->promotion_id)) {
         $array['etudiant_promotion'] = Auth::user()->user->promotion()->first();
     }
     $array['profile'] = ProfileEtudiant::where('etudiant_id', $array['etudiant']->id)->first();
     //Si aucune promotion n'est liée à l'étudiant
     if (isset($array['etudiant_promotion'])) {
         $array['specialites'] = Promotion::find($array['etudiant']->promotion_id)->specialites()->get();
     }
     $array['etudiant_specialite'] = Auth::user()->user->specialite()->first();
     //calculer le pourcentage du profil de l'etudiant
     $array['pourcentage'] = $this->getPourcentageProfilEtudiant();
     return View::make('etudiant.profil')->with($array);
 }