/**
  * Show Category.
  *
  * @return Response
  */
 public function show(Request $request, $slug)
 {
     $category = Category::where('slug', $slug)->first();
     if (!$category) {
         \App::abort(404);
     }
     // pagination
     $session_type = 'product';
     if (!$request->session()->has('order_by')) {
         $request->session()->put($session_type . '.order_by', 'created_at');
     }
     if (!$request->session()->has('order_dir')) {
         $request->session()->put($session_type . '.order_dir', 'desc');
     }
     if ($request->getorder_by) {
         $request->session()->put($session_type . '.order_by', $request->order_by);
     }
     if ($request->getorder_dir) {
         $request->session()->put($session_type . '.order_dir', $request->order_dir);
     }
     $orderby = $request->session()->get($session_type . '.order_by') == 'created_at' ? $request->session()->get($session_type . '.order_by') : $request->session()->get('language') . '.' . $request->session()->get($session_type . '.order_by');
     $limit = $request->session()->get('limit');
     $products = Product::whereIn('_id', $category->products)->orderBy($orderby, $request->session()->get($session_type . '.order_dir'))->paginate($limit);
     return view('themes/basic/categories/show', ['category' => $category, 'products' => $products]);
 }
Example #2
0
 /**
  * Display the specified category.
  *
  * @param  int $id
  * @return Response
  */
 public function show($alias, Advertisement $advertisement)
 {
     $category = Category::where('alias', $alias)->first();
     $ads = $advertisement->approved()->where('category_id', $category->id)->orderBy('id', 'desc')->paginate(3);
     return view('welcome', ['ads' => $ads]);
     //->nest('child','task.index');
 }
 public function update(StoreCategoryRequest $request, $categoryId)
 {
     $input = $request->all();
     $input['slug'] = str_replace(' ', '_', strtolower($input['name']));
     $category = Category::where('id', $categoryId)->update($input);
     return $this->createResponse($category);
 }
Example #4
0
 /**
  * Список новостей
  * @param Request $request
  * @param null $alias
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function feed(Request $request, $alias = null)
 {
     $page = Paginator::resolveCurrentPage('page');
     $per_page = config('paginator.per_page');
     $category = Category::where('alias', $alias)->first();
     $order_by = $request->input('order_by');
     $articles = Article::whereRaw('1=1');
     switch ($order_by) {
         case 'name_desc':
             $articles->orderBy('name', 'desc');
             break;
         case 'name_asc':
             $articles->orderBy('name', 'asc');
             break;
         case 'date_desc':
             $articles->orderBy('created_at', 'desc');
             break;
         case 'date_asc':
             $articles->orderBy('created_at', 'asc');
             break;
         default:
             $articles->orderBy('created_at', 'desc');
             break;
     }
     if (is_null($category)) {
         $articles = $articles->paginate($per_page);
     } else {
         $articles = $articles->where('category_id', $category->id)->paginate($per_page);
     }
     if ($order_by) {
         $articles->appends('order_by', $order_by);
     }
     return view('pages/feed', ['articles' => $articles, 'category' => $category, 'page' => $page, 'order_by' => $order_by]);
 }
 public function __construct(Route $route)
 {
     $this->middleware(function ($request, $next) {
         // if session is not set get it from .env SHOP_CODE
         if (!$request->session()->has('shop')) {
             $shop = Shop::where('code', config('app.shop_code'))->first();
             $request->session()->put('shop', $shop->id);
         }
         // if limit is not set default pagination limit
         if (!$request->session()->has('limit')) {
             $request->session()->put('limit', 100);
         }
         // if session is not set reset the session for the language
         if (!$request->session()->has('language')) {
             $request->session()->put('language', config('app.locale'));
         }
         // if session is not set reset the session for the basket
         if (!$request->session()->has('basket')) {
             $request->session()->put('basket', ['subtotal' => 0, 'count' => 0, 'items' => []]);
         }
         // global list of categories
         $categories = Category::where('shop_id', $request->session()->get('shop'))->orderBy('order', 'asc')->get();
         // share globals
         view()->share('language', $request->session()->get('language'));
         view()->share('categories', $categories);
         return $next($request);
     });
     // add controller & action to the body class
     $currentAction = $route->getActionName();
     list($controller, $method) = explode('@', $currentAction);
     $controller = preg_replace('/.*\\\\/', '', $controller);
     $action = preg_replace('/.*\\\\/', '', $method);
     view()->share('body_class', $controller . '-' . $action);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $groupOption = "food";
     $menuOption = "categories";
     $categories = Category::where('restaurant_id', Auth::user()->id)->get();
     return view('backend.pages.categories')->with(compact('categories', 'menuOption', 'groupOption'));
 }
 public function confirmUnpublished(Product $product)
 {
     $authors_list = $product->is->authors->lists('lastname');
     $category = Category::where('id', $product->organizations->first()->pivot->cat_id)->first(['name']);
     $editor = $product->is->editor->e_name;
     return view('admin.products.unpublished.confirm', compact('product', 'authors_list', 'category', 'editor'));
 }
Example #8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $videos = glob(public_path() . '/b/*');
     usort($videos, function ($a, $b) {
         $a = (int) basename($a, '.webm');
         $b = (int) basename($b, '.webm');
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     });
     $category = \App\Models\Category::where('shortname', '=', 'misc')->first();
     $user = \App\Models\User::find(1);
     foreach ($videos as $video) {
         if (\App\Models\Video::whereFile(basename($video))->count() > 0) {
             continue;
         }
         $v = new \App\Models\Video();
         $v->user()->associate($user);
         $v->category()->associate($category);
         $v->hash = sha1_file($video);
         $v->file = basename($video);
         $v->save();
     }
 }
Example #9
0
 public function getShoes()
 {
     $categories = Category::where("is_home", 1)->orderBy("sort_order", "asc")->get();
     foreach ($categories as $cat) {
         $cat->image = asset("public/admin/uploads/catalog/category/" . json_decode($cat->images, true)[0]);
     }
     return $categories;
 }
 public function postAction(Request $request)
 {
     if ($request->input('id')) {
         foreach ($request->input('id') as $k => $v) {
             $cate = Category::where("id", $v)->delete();
         }
     }
     return redirect('admin/category/index');
 }
 /**
  * Data for Select element
  */
 public static function GetEditList($id)
 {
     $result = [];
     $list = Category::where('id', '!=', $id)->get();
     foreach ($list as $k => $v) {
         $result[$v->id] = $v->name;
     }
     return $result;
 }
Example #12
0
 public function category_select(Request $request)
 {
     $lang = $request->session()->get('language');
     $categories = [];
     $results = Category::where('shop_id', '=', $request->session()->get('shop'))->get();
     foreach ($results as $category) {
         $categories[$category->id] = isset($category->{$lang}['name']) ? $category->{$lang}['name'] : $category->default['name'];
     }
     return $categories;
 }
 /**
  * Returns page with form for editing existing category
  *
  * @param  App\Models\Category $category Instance of Category model
  * @return View
  */
 public function edit(Category $category)
 {
     /**
      * Select id-slug list of all categories except itself, needed
      * for choosing parent category
      */
     $categories = Category::where('id', '<>', $category->id)->lists('slug', 'id');
     $categories[''] = 'No parent (root)';
     return view('admin.categories.edit')->with(compact('category', 'categories'));
 }
Example #14
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     //if(!parent::authorize()) return false;
     if ($this->category) {
         if ($this->user()->isAdmin()) {
             return true;
         }
         return Category::where('id', $this->category)->where('user_id', $this->user()->id)->exists();
     }
     return true;
 }
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function show(Request $request)
 {
     $stats['categories'] = Category::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['products'] = Product::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['customers'] = User::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['pages'] = Page::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['blogs'] = Blog::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['orders'] = Order::where('shop_id', '=', $request->session()->get('shop'))->count();
     $stats['revenue'] = Order::where('shop_id', '=', $request->session()->get('shop'))->sum('total');
     return view('admin/dashboard', ['stats' => $stats]);
 }
 public function child_node($parent_id)
 {
     static $result = array();
     $category = Category::where('parent_id', $parent_id)->get();
     if ($category) {
         foreach ($category as $cate) {
             $result[] = $cate->id;
             $this->get_child($cate->id);
         }
     }
     return $result;
 }
Example #17
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id, $sid)
 {
     $catDetails = Category::where('id', $id)->with(['products' => function ($query) use($sid) {
         $query->where('subcat_id', $sid);
     }])->first();
     /*
             $catDetails = \App\Category::where('id', $id)->
        with('product')->first();
     */
     $subCatDesc = SubCatLevel1::find($sid)->description;
     return view('category', ['subCatDesc' => $subCatDesc])->with('catDetails', $catDetails);
 }
Example #18
0
 public function index()
 {
     if (empty(Input::get('category'))) {
         $categories = Category::all();
         $articles = Article::paginate(15);
         return view('article.index')->withArticles($articles)->withCategories($categories);
     } else {
         $category = Input::get('category');
         $articles = Category::where('name', $category)->article;
         return view('article.index')->withArticles($articles)->withCategories($category);
     }
 }
Example #19
0
 private function getCategoriesByRecursion($cat_id)
 {
     // M A K E   P R I V A T E FUNCTION
     $record = Category::find($cat_id);
     $dewey = $record->dewey;
     $i = $record->level;
     for ($i; $i >= 1; $i--) {
         $recordSet = Category::where('parent_id', $record->parent_id)->where('level', $i)->where('dewey', $dewey)->get()->lists('name_cat', 'cat_id')->all();
         $categoryLists[$i] = ['selected' => $record->cat_id, 'category-list' => $recordSet, 'categID' => $record->level, 'id' => $record->id, 'parent_id' => $record->parent_id];
         $record = Category::where('cat_id', $record->parent_id)->where('level', $i - 1)->where('dewey', $dewey)->first();
     }
     return $categoryLists;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $menuOption = "analitics";
     $restaurant = Restaurant::where('user_id', Auth::user()->id)->first();
     $dishes = Dish::where('restaurant_id', $restaurant->id)->get();
     $categories = Category::where('restaurant_id', $restaurant->id)->get();
     $dishesIds = Dish::where('restaurant_id', $restaurant->id)->lists('id');
     $categoriesIds = Category::where('restaurant_id', $restaurant->id)->lists('id');
     $dishesAnalytics = Analitic::where('related_table', 'dishes')->whereIn('related_id', $dishesIds)->get();
     $firstDay = Analitic::where('related_table', 'dishes')->whereIn('related_id', $dishesIds)->min('date');
     $categoriesAnalytics = Analitic::where('related_table', 'categories')->whereIn('related_id', $categoriesIds)->get();
     return view('backend.pages.analitics')->with(compact('dishesAnalytics', 'menuOption'));
 }
Example #21
0
 public function getIndex(Request $request)
 {
     $attach['categories'] = Category::where("user_id", "=", "0")->get();
     $attach['user'] = $this->user;
     if (isset($request->id)) {
         $attach['plan'] = $this->user->plans()->where('id', '=', $request->id)->first();
     } else {
         if (Session::has('Plan')) {
             $attach['plan'] = $this->user->plans()->where('id', '=', Session::get('Plan'))->first();
         }
     }
     return view('plan.create')->with($attach);
 }
 public function categories($search = null, $paginate = true)
 {
     $result = null;
     if ($paginate) {
         if (!is_null($search) && !empty($search)) {
             return Category::where('name', 'like', "%{$search}%")->paginate(env('PAGINATION_ITEMS', 10));
         }
         return Category::paginate(env('PAGINATION_ITEMS', 10));
     }
     /**
      * Este, sem paginação, visa atender à API
      */
     return Category::where('name', 'like', "%{$search}%")->get();
 }
Example #23
0
 public function getSubCategory()
 {
     if (\Request::ajax()) {
         $option_value = \Input::get('value') == 'null' ? '' : \Input::get('value');
         // Το Value του option του combobox
         $parent = \Input::get('parent');
         //το Id του τρέχων combobox
         $dewey = \Input::get('dewey');
         //ελέγχει αν το checkbox είναι true ή false
         $child = \Input::get('child');
         $parentID = \Input::get('parentID');
         if (!isset($parentID)) {
             $parentID = '';
         }
         $data = array();
         if ($dewey == 'true') {
             // εαν το checkbox dewey είναι ΝΑΙ τότε
             $sql_dewey = 1;
             $data['select'] = Category::where('dewey', $sql_dewey)->where('parent_id', $option_value)->where('level', $child)->get()->lists('name_cat', 'cat_id');
             // τα δεδομένα του combobox
             $selectRecord = Category::where('dewey', $sql_dewey)->where('parent_id', $option_value)->where('level', $child)->first();
             if ($selectRecord) {
                 $data['parentID'] = $selectRecord->parent_id;
             }
             if ($parent > 0) {
                 //εαν έχει επιλεγεί κάποιο combobox με dewey να είναι ΝΑΙ (ενεργοποιημένο) τότε
                 $record = Category::where('cat_id', $option_value)->where('parent_id', $parentID)->where('level', $parent)->where('dewey', $sql_dewey)->first();
                 //επιστρέφει το ID της κατηγορίας
                 $data['categoryID'] = $record->id;
             }
             // διαφορετικά δεν επιστρέφει categoryID
         } else {
             // αλλιώς αν το dewey είναι ΟΧΙ - false - ΑΠΕΝΕΡΓΟΠΟΙΗΜΕΝΟ τοτε
             $sql_dewey = 0;
             $data['select'] = Category::where('dewey', $sql_dewey)->where('level', $child)->get()->lists('name_cat', 'cat_id');
             // επιστρέφει το combobox με δεδομένα
             if ($parent > 0) {
                 // εαν έχει επιλεγεί κάποιο combobox τότε
                 $record = Category::where('cat_id', $option_value)->where('level', $parent)->where('dewey', $sql_dewey)->first();
                 // επιστρέφει το ID της κατηγορίας διαφορετικά τίποτα
                 $data['categoryID'] = $record->id;
                 $data['parentID'] = $record->parent_id;
             }
         }
         $data['sub'] = $child;
         $data['value_option'] = $option_value;
         return $data;
     }
 }
 public function category(Advertisement $advertModel, $locale, $category)
 {
     $cur_category = Category::where('url', $category)->first();
     if (!$cur_category) {
         abort(404);
     }
     $categoryModel = new Category();
     $categories = $categoryModel->get_order_count();
     $title = $cur_category->{$locale . '_title'};
     $advertisements = Advertisement::where('published', 1)->where('status', '!=', 'top')->where('category_id', $cur_category->id)->orderBy('created_at', 'desc')->has('category')->paginate(15);
     $top_advertisements = Advertisement::where('published', 1)->where('status', '=', 'top')->where('category_id', $cur_category->id)->orderBy('created_at', 'desc')->has('category')->get();
     $b1_baner = Baner::where('type', 'b1')->get();
     $popular_advert = $advertModel->get_popular_advert();
     return view('site.advertisements.index')->with('title', $title)->with('categories', $categories)->with('advertisements', $advertisements)->with('top_advertisements', $top_advertisements)->with('b1_baner', $b1_baner)->with('popular_advert', $popular_advert);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $l = Input::get('data');
     $data['lists'] = Category::where('p_id', $id)->get();
     if ($id != 0) {
         $r = Category::find($id);
         $data['test'] = [$r->p_id, $r->location, $r->c_id];
     } else {
         $data['test'] = [0, 'top'];
     }
     if ($l == 'seminar') {
         $data['notes'] = Notebook::where('c_id', $id)->get();
     }
     return response()->json($data);
 }
Example #26
0
 /**
  * Get Menu Items
  * @param $parent_id
  * @return array
  */
 public static function getMenuData($parent_id)
 {
     $categories = array();
     $result = Category::where('parent_id', $parent_id)->get();
     foreach ($result as $parentCategory) {
         $category = array();
         $category['id'] = $parentCategory->cat_id;
         $category['name'] = $parentCategory->cat;
         $category['parent_id'] = $parentCategory->parent_id;
         $category['banner'] = $parentCategory->m_img;
         $category['sub_cat'] = self::getMenuData($category['id']);
         $categories[$parentCategory->cat_id] = $category;
     }
     return $categories;
 }
Example #27
0
 public function category($category)
 {
     $page = 'catalog';
     $title = Menu::where('key', $page)->value('name');
     $menuHtml = $this->menuHtml($page);
     $menuItems = Menu::all();
     $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
     $page = Page::where('key', $page)->first();
     $categories = Category::orderBy('sort', 'asc')->get();
     $products = Product::with(['category' => function ($query) use($category) {
         $query->where('key', '=', $category);
     }])->get();
     $smallCart = $this->smallCart();
     $currentCategory = Category::where('key', $category)->first();
     return view('site.catalog', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'title' => $title, 'page' => $page, 'products' => $products, 'categories' => $categories, 'params' => $this->params(), 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'currentCategory' => $currentCategory]);
 }
Example #28
0
 private function _update($id, $name, $parent_key, $ordinal, $active)
 {
     try {
         $data = ['name' => $name, 'parent_key' => $parent_key, 'ordinal' => $ordinal, 'active' => $active];
         $affectedRows = Category::where('id', '=', $id)->update($data);
         if ($affectedRows) {
             $this->message = 'Sửa danh mục thành công';
         } else {
             $this->error_message = 'Error !';
             $this->error = true;
         }
     } catch (Exception $e) {
         $this->error_message = $e->getMessage();
         $this->error = true;
     }
     return $data;
 }
Example #29
0
 public function getIndex()
 {
     $attach['categories'] = Category::where("user_id", "=", "0")->get();
     $attach['user'] = $this->user;
     if (isset($request->id)) {
         $attach['plan'] = $this->user->plans()->where('id', '=', $request->id)->first();
     } else {
         if (Session::has('Plan')) {
             $attach['plan'] = Plan::find(Session::get('Plan'));
         }
     }
     if (isset($attach['plan'])) {
         if ($month = $attach['plan']->months()->orderBy('id', 'desc')->first()) {
             $attach['daily'] = $month->days()->where('date', '>=', date('Y-m-d'))->where('date', '<=', date('Y-m-d', strtotime('+1 day', strtotime(date('Y-m-d')))))->first();
         }
     }
     return view('expense.create')->with($attach);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $author = User::whereHas('role', function ($q) {
         $q->where('slug', 'admin');
     })->first();
     $categories = Category::where('is_active', 1)->get();
     $postsRecents = Post::where('is_active', 1)->where('seen', 1)->orderBy('created_at', 'desc')->take(3)->get();
     $postsPopular = Post::where('is_active', 1)->where('seen', 1)->orderBy('nview', 'desc')->take(3)->get();
     $commentsRecents = Comment::where('seen', 1)->orderBy('created_at', 'desc')->take(3)->get();
     $tags = Tag::all();
     $INFO_SITE = Admin::first();
     view()->share('author', $author);
     view()->share('categories', $categories);
     view()->share('tags', $tags);
     view()->share('postsRecents', $postsRecents);
     view()->share('postsPopular', $postsPopular);
     view()->share('commentsRecents', $commentsRecents);
     view()->share('INFO_SITE', $INFO_SITE);
 }