/**
  * @Post("EDIT-CATEGORIE")
  * @return Redirect
  */
 public function posteditcategorie(Request $request)
 {
     $one = Categorie::find($request->get('id'));
     $one->nom = $request->nom;
     $one->save();
     return redirect('/categories');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request, $slugCategorie)
 {
     $cat = Categorie::where('cat_slug', $slugCategorie)->first();
     if ($request->has('format')) {
         if ($request->input('format') == 'json') {
             $sscats = $cat->sscats;
             $tabsscats = array();
             foreach ($sscats as $sscat) {
                 $tabsscats[] = ['slug' => $sscat->sscat_slug, 'nom' => $sscat->sscat_nom];
             }
             return response()->json($tabsscats);
         }
     }
     return view('souscategorie.index', ['cat' => $cat]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $categories = Categorie::all();
     return view('categorie.index', ['categories' => $categories]);
 }
 /**
  * @Post("/editoperationper")
  *
  */
 public function posteditoperationper(Request $request)
 {
     $et = Operationper::find($request->get('id'));
     $user = User::find(Auth::user()->id);
     // ****************************************************
     if ($et->type_dr == "depense" and $et->mode_paiement == "poche") {
         $user->solde_poche = $user->solde_poche + $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale + $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "revenue" and $et->mode_paiement == "bank") {
         $user->soldebancaire = $user->soldebancaire - $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale - $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "depense" and $et->mode_paiement == "bank") {
         $user->soldebancaire = $user->soldebancaire + $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale + $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "revenue" and $et->mode_paiement == "poche") {
         $user->solde_poche = $user->solde_poche - $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale - $request->montant * $et->cpt;
         $user->save();
     }
     // *******************************************************
     $et->frequence = $request->frequence;
     $et->nom = $request->nom;
     $et->type_dr = $request->type_dr;
     $et->montant = $request->montant;
     $et->mode_paiement = $request->mode_paiement;
     $et->description = $request->description;
     $et->etiquette_id = $request->etiquette;
     $et->categorie_id = $request->categorie;
     $et->date_d = $request->date_d;
     $et->date_f = $request->date_f;
     // *******************************************************
     if ($et->type_dr == "depense" and $et->mode_paiement == "poche") {
         $user->solde_poche = $user->solde_poche - $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale - $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "revenue" and $et->mode_paiement == "bank") {
         $user->soldebancaire = $user->soldebancaire + $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale + $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "depense" and $et->mode_paiement == "bank") {
         $user->soldebancaire = $user->soldebancaire - $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale - $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "revenue" and $et->mode_paiement == "poche") {
         $user->solde_poche = $user->solde_poche + $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale + $request->montant * $et->cpt;
         $user->save();
     }
     // *******************************************************
     $et->save();
     return redirect('/operationpers')->with(['etiquette' => Etiquette::all(), 'categorie' => Categorie::all(), 'operationpers' => Operationper::where('user_id', \Auth::user()->id)->with('etiquette', 'categorie')->get()]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slugCategorie, $slugSousCategorie, $slugProduit)
 {
     $cat = Categorie::where('cat_slug', $slugCategorie)->first();
     $sscat = SousCategorie::where('sscat_slug', $slugSousCategorie)->first();
     $produit = Produit::where('prod_slug', $slugProduit)->first();
     // augmenter nbr vue
     $produit->prod_stat = $produit->prod_stat + 1;
     $produit->save();
     $listePrix = array();
     foreach ($sscat->produits as $prod) {
         $listePrix[$prod->prod_slug] = PrixGestion::getRangePrix($prod);
     }
     $form = array();
     $proprietes = $produit->caracteristiques->groupBy('car_fk_proprietes');
     foreach ($proprietes as $prop) {
         $tmp = array();
         foreach ($prop as $carac) {
             $tmp[] = $carac;
         }
         $form[$prop->first()->propriete->prop_nom] = $tmp;
     }
     return view('produit.show', ['cat' => $cat, 'sscat' => $sscat, 'produit' => $produit, 'listePrix' => $listePrix, 'form' => $form]);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $categories = Categorie::all();
     view()->share('categories', $categories);
 }