/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (!Input::has('typeId')) {
         return redirect()->route('dashboard.category.index', ['typeId' => 1]);
     }
     $typeId = Input::get('typeId');
     $assign['categorys'] = $this->Category->whereRaw('parent_id = 0 and type_id = ' . $typeId)->orderByRaw('weight asc, id asc')->get();
     return view('dashboard.category.index', $assign);
 }
示例#2
0
 public function index(Request $request)
 {
     $search = \Request::get('search');
     //<-- we use global request to get the param of URI
     if ($search) {
         $allCategory = Category::whereRaw('category_name = ?', [$search])->orderBy('id', 'asc')->paginate(5);
     } else {
         $allCategory = Category::orderBy('id', 'asc')->paginate(5);
     }
     return view('Category.index', ['Categories' => $allCategory]);
 }
示例#3
0
 public function affiche($id)
 {
     $title = "voiture";
     $options = $idCategries = array();
     $customers = array();
     $customer = Customer::all();
     foreach ($customer as $c) {
         $customers[$c->id] = $c->name . ' ' . $c->last_name;
     }
     if (isset($id) && !empty($id)) {
         $car = Car::findOrFail($id);
         $options = current($car->optioncars()->lists('option_id'));
         if (!empty($options)) {
             $ids = implode(",", $options);
             //option ID's
             $prices = OptionCar::whereRaw('option_id  in (' . $ids . ' ) and car_id=' . $id . ' order by option_id')->get();
             foreach ($prices as $price) {
                 $prices_car[$price->option_id]['price'] = $price->option_price;
                 $prices_car[$price->option_id]['id'] = $price->id;
             }
             $optionsList = Option::whereRaw('id  in (' . $ids . ' ) order by id')->get();
             foreach ($optionsList as $option) {
                 $el = $option->category_id;
                 if (!in_array($el, $idCategries)) {
                     //if not exist in array
                     array_push($idCategries, $el);
                 }
             }
             $idCategries = implode(",", $idCategries);
             $categories = Category::whereRaw('id  in (' . $idCategries . ')')->get();
             foreach ($categories as $cat) {
                 foreach ($optionsList as $option) {
                     if ($option['category_id'] == $cat['id']) {
                         $listcategories[$cat->id]['name'] = $cat->name_category;
                         $listcategories[$cat->id]['options'][$option->id]['name'] = $option->name;
                         $listcategories[$cat->id]['options'][$option->id]['description'] = $option->description;
                         $listcategories[$cat->id]['options'][$option->id]['price'] = $prices_car[$option->id]['price'];
                         $listcategories[$cat->id]['options'][$option->id]['id'] = $prices_car[$option->id]['id'];
                     }
                 }
             }
             return view('Cars/car-details', ['categories' => $listcategories, 'title' => $title, 'car' => $car, 'customers' => $customers]);
         } else {
             return view('Cars/car-details', ['categories' => null, 'car' => $car, 'title' => $title]);
         }
     }
 }
 public function getSlug($title, $allow_overlap = true)
 {
     $slug = str_slug($title);
     $slugCount = count(Category::whereRaw("slug REGEXP '^{$slug}(-[0-9]*)?\$'")->get());
     if ($allow_overlap == false) {
         return $slugCount > 0 ? false : $slug;
     } else {
         return $slugCount > 0 ? "{$slug}-{$slugCount}" : $slug;
     }
 }
示例#5
0
 public function getCategoriesFront($id_car)
 {
     //$car=Car::where('id',$id_car)->get();
     $idCategries = array();
     $car = Car::findOrFail($id_car);
     $options = current($car->optioncars()->lists('option_id'));
     if (!empty($options)) {
         $ids = implode(",", $options);
         //option ID's
         $prices = OptionCar::whereRaw('option_id  in (' . $ids . ' ) and car_id=' . $id_car . ' order by option_id')->get();
         foreach ($prices as $price) {
             $prices_car[$price->option_id]['price'] = $price->option_price;
             $prices_car[$price->option_id]['id'] = $price->id;
         }
         $optionsList = Option::whereRaw('id  in (' . $ids . ' ) order by id')->get();
         foreach ($optionsList as $option) {
             $el = $option->category_id;
             if (!in_array($el, $idCategries)) {
                 //if not exist in array
                 array_push($idCategries, $el);
             }
         }
         $idCategries = implode(",", $idCategries);
         $categories = Category::whereRaw('id  in (' . $idCategries . ')')->get();
         foreach ($categories as $cat) {
             foreach ($optionsList as $option) {
                 if ($option['category_id'] == $cat['id']) {
                     $listcategories[$cat->id]['name'] = $cat->name_category;
                     $listcategories[$cat->id]['icone'] = $cat->icon;
                     $listcategories[$cat->id]['options'][$option->id]['name'] = $option->name;
                     $listcategories[$cat->id]['options'][$option->id]['description'] = $option->description;
                     $listcategories[$cat->id]['options'][$option->id]['price'] = $prices_car[$option->id]['price'];
                     $listcategories[$cat->id]['options'][$option->id]['id'] = $prices_car[$option->id]['id'];
                 }
             }
         }
         return $listcategories;
     }
 }