public static function viewCategories($request) { $categories = Category::with(['devices'])->latest('updated_at'); $categories = $categories->where('name', 'LIKE', '%' . $request->get('filter') . '%')->paginate(25); $categories->setPath('/'); return view('home', compact('categories')); }
/** * Retrieve all categories with their products * Products can have a category_id_sub : if it is not null, a category with sub_ids can be shown on screen * * @return mixed */ public function index() { return Category::with(['products' => function ($q) { $q->select(['products.id', 'category_id', 'name', 'price', 'visible', 'sort', 'category_id_sub']); $q->orderBy('sort'); }])->orderBy('sort')->get(); }
/** * Get all categories with childs ordered by priority * * @return collection */ public static function getAll() { $categories = Category::with(['childs' => function ($query) { $query->orderBy('priority', 'desc'); }])->where('parent_id', null)->orderBy('priority')->get(); return $categories; }
/** * @param $slug * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function showSingleCategory($slug) { $categories = Category::with('products')->where('is_active', true)->has('products')->get(); $category = Category::findBySlug($slug); $products = $category->products; return view('frontend.categories.showCategory', compact('categories', 'category', 'products')); }
public function destroy(Request $request) { $model = Category::with('articles', 'announcements')->find($request->id); if (empty($model)) { Flash::error('Impossible de supprimer cette catégorie.'); return Redirect::back(); } $announcements = $model->announcements(); $articles = $model->articles(); if (!empty($announcements)) { foreach ($announcements as $a) { $a->update(['category_id' => 1]); } } if (!empty($articles)) { foreach ($articles as $a) { $a->update(['category_id' => 1]); } } $name = $model->name; $model->delete(); makeModification('categories', 'The category « ' . $name . ' » has been removed.'); Flash::success('La catégorie a bien été supprimé.'); return Redirect::back(); }
private static function updatePostCount() { foreach (Category::with('posts')->get() as $category) { $category->post_count = $category->posts()->count(); $category->save(); } }
public function viewMenus($id = '') { $categories = Category::with('product')->lightSelection()->store()->full()->orderBy('name')->get()->toArray(); $actualCategory = []; findfather($actualCategory, $categories, $id); $panel = ['left' => ['width' => '3', 'class' => 'categories-panel'], 'center' => ['width' => '9']]; return view('categories.menus', ['panel' => $panel, 'categories' => orderByParents($categories), 'actualCategory' => $actualCategory]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $record = Category::with('user')->get(); if (!$record) { return View::make('errors.404'); } //return View::make('company_category.index')->with('data', $record); return View::make('company_category.index', ['data' => $record, 'categories' => $this->getCategoryListAsJson()]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $categories = Category::with(['threads' => function ($query) { $query->orderBy('updated_at', 'desc'); }, 'threads.posts' => function ($query) { $query->orderBy('created_at', 'asc'); }, 'threads.posts.user'])->get(); return view('categories.index', compact('categories')); }
/** * Display a listing of the resource. * * @param $categoryId * @return Response */ public function index($categoryId) { $category = Category::with(['threads' => function ($query) { $query->orderBy('updated_at', 'desc'); }, 'threads.posts' => function ($query) { $query->orderBy('created_at', 'asc'); }, 'threads.posts.user'])->findOrFail($categoryId); return view('threads.index', compact('category')); }
/** * Отображает список категорий. * * @return Response */ public function getIndex() { // Ищем фирму по короткому названию $data['company'] = Company::whereShortTitle($this->companyName)->first(); // Получаем список групп категорий $data['categories'] = Category::with('group_category')->with('parent_category')->whereHas('group_category', function ($query) use($data) { $query->where('company_id', '=', $data['company']->id); })->get(); return view('admin.companies.catalog.categories.index', $data); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $category = Category::with(['threads', 'threads.posts'])->findOrFail($id); foreach ($category->threads as $thread) { $thread->posts()->delete(); } $category->threads()->delete(); $category->delete(); return redirect()->route('admin.categories.index'); }
public function getCategoriesAdmin($departmentId = null) { if ($departmentId) { $categories = Category::with('langs')->where('department_id', $departmentId)->sort()->get(); } else { $categories = Category::with('langs')->sort()->get(); } $categories = $this->loadLangs($categories); return $categories; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $user = new Users(); $user->fill($request->all()); $user->password = Hash::make($request->input('password')); $user->save(); $data['partner'] = Partner::orderBy('created_at', 'asc')->get(); $data['category'] = Category::with('SubCategory')->orderBy('created_at', 'asc')->get(); return view('site.success', $data); }
public static function getRooms($q) { $json = array(); $categories = Category::with(['rooms' => function ($query) use($q) { $query->where('name', 'LIKE', '%' . $q . '%'); }])->get(); foreach ($categories as $category) { foreach ($category->rooms as $room) { $json[] = ['category_id' => $category->id, 'room_id' => $room->id, 'category_name' => $category->name, 'room_name' => $room->name, 'category_min' => $category->min_capacity, 'category_max' => $category->max_capacity, 'category_price' => $category->price]; } } return $json; }
public static function createCustomerReservation($reservation_date) { $packages = Entrance::all(); $dates = explode('&', $reservation_date); $start_date = $dates[0]; $end_date = $dates[1]; $entrances = Entrance::with(['entrance_type'])->get(); $room_ids = DB::table('rooms')->join('reservation_room', function ($join) { $join->on('rooms.id', '=', 'reservation_room.room_id'); })->where('reservation_room.date_reserved', '=', $start_date)->where('reservation_room.date_reserved', '<', $end_date)->pluck('reservation_room.room_id')->groupBy('rooms.id'); # Fetch all the room that is not equal to the given id's $categories = Category::with(['rooms' => function ($query) use($room_ids) { $query->whereNotIn('id', $room_ids); }])->get(); return view('reservation.form', compact('start_date', 'end_date', 'categories', 'entrances', 'packages')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // get user's categories $categories = Category::with('transactions')->where('user_id', Auth::user()->id)->orderBy('name', 'ASC')->get(); // get all transactions of the user $transactions = Transaction::where('user_id', Auth::user()->id)->get(); // calculate total income and total expense $incomeTotal = $transactions->where('type', 'DEPOSIT')->sum('amount'); $expenseTotal = $transactions->where('type', 'WITHDRAWAL')->sum('amount'); // get uncategorized transactions $transactions = Transaction::where('user_id', Auth::user()->id)->whereNull('category_id')->get(); // stuff to pass into view $title = "Categories"; $heading = "Categories"; return view('categories.index', compact('categories', 'transactions', 'incomeTotal', 'expenseTotal', 'title', 'heading')); }
/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { $categories = Category::with('children', 'products')->where('parent_id', '=', 0)->orderBy('did')->get(); $hotpros_id = Salesstats::groupBy('product_id')->take(16)->get(); $hotpros_id = $hotpros_id->lists('product_id'); $hotpros = Product::with('images')->has('images')->has('prices')->wherein('id', $hotpros_id)->take(16)->get(); $globals = DB::table('globalsettings')->get(); $dts = DB::table('deliverytimes')->where('active', true)->get(); foreach ($dts as $dt) { $dt->start = Carbon::parse($dt->start)->format('h:ia'); $dt->stop = Carbon::parse($dt->stop)->format('h:ia'); } $settings = []; foreach ($globals as $global) { $name = $global->name; $value = $global->value; $settings[$name] = $value; } $offers = Offer::with(['categories', 'categories.products' => function ($q) { $q->has('images'); }, 'brands', 'brands.products' => function ($q) { $q->has('images'); }, 'products' => function ($q) { $q->has('images'); }, 'products.images', 'products.prices'])->where('active', true)->where('start', '<=', Carbon::today()->toDateString())->where('end', '>=', Carbon::today()->toDateString())->take(16)->get(); //dd($offers); $feedbacks = Feedback::with('user')->take(8)->get(); if ($user = Sentinel::check()) { $user = User::findorfail($user->id); $flashes = Flashtext::where('active', '1')->get(); $areas = Area::where('deliverable', '1')->get(); $viewpros_id = Viewstats::where('user_id', $user->id)->take(16)->get(); //dd($viewpros_id); $viewpros_id = $viewpros_id->lists('product_id'); $viewpros = Product::with('images')->has('images')->has('prices')->wherein('id', $viewpros_id)->take(16)->get(); $view->with(['user' => $user, 'flashes' => $flashes, 'areas' => $areas, 'hotpros' => $hotpros, 'viewpros' => $viewpros, 'offers' => $offers, 'settings' => $settings, 'dts' => $dts, 'feedbacks' => $feedbacks, 'categories' => $categories]); } else { $flashes = Flashtext::where('active', '1')->get(); $areas = Area::where('deliverable', '1')->get(); $viewpros_id = Viewstats::where('user_id', 0)->take(16)->get(); $viewpros_id = $viewpros_id->lists('product_id'); $viewpros = Product::with('images')->has('images')->has('prices')->wherein('id', $viewpros_id)->take(16)->get(); $view->with(['flashes' => $flashes, 'areas' => $areas, 'hotpros' => $hotpros, 'viewpros' => $viewpros, 'offers' => $offers, 'settings' => $settings, 'dts' => $dts, 'feedbacks' => $feedbacks, 'categories' => $categories]); } }
public function newsDetails($slug) { $getNews = DB::table('news')->where('slug', $slug)->first(); $categories = Category::with('subCategory')->get(); $allfeatures = DB::table('featured')->join('products', 'products.id', '=', 'featured.product_id')->get(); $popular1 = DB::table('otherproducts')->where('type', 'popular')->first(); $latest1 = DB::table('otherproducts')->where('type', 'latest')->first(); $popular = DB::table('otherproducts')->where('type', 'popular')->orderBy('id', 'DESC')->get(); $latest = DB::table('otherproducts')->where('type', 'latest')->orderBy('id', 'DESC')->get(); return view('pages.news')->with(array('categories' => $categories, 'feature' => $allfeatures, 'popular1' => $popular1, 'latest1' => $latest1, 'popular' => $popular, 'latest' => $latest, 'details' => $getNews)); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $categories = Category::with('articles')->latest()->get(); return view('blog.cats.index', compact('categories')); }
/** * Show a specific category * * @return response */ public function showCategory(Request $request, $category_id) { $category = Category::with('bookings')->find($category_id); return response()->json($category); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $categories = Category::with('Photo')->get(); return view('category.index', compact('categories')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $data['item'] = Items::findOrFail($id); $data['category'] = Category::with('SubCategory')->orderby('created_at', 'asc')->get(); $data['color'] = ItemColors::all(); $data['size'] = ItemSize::all(); if (is_dir(public_path() . '/uploads/photos/' . $id . '/')) { $photos = scandir(public_path() . '/uploads/photos/' . $id . '/', 1); $files = array_diff($photos, array('.', '..')); } else { $files = []; } $data['photos'] = $files; return view('admin.item-add', $data)->with('obj', $data); }
/** * Get the query object to be processed by datatables. * * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder */ public function query() { $categories = Category::with('articles')->whereLanguageId(session('current_lang')->id); return $this->applyScopes($categories); }
public static function getCategoryById($ids) { return Category::with('children')->findOrFail($ids, ['id', 'title']); }
public function getIndex() { return Category::with(['tags'])->get(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $categories = Category::with('postsCount')->get(); return view('admin.category_create', ['categories' => $categories]); }
public function categoriesUpdate() { $categories = Category::with('posts')->get(); foreach ($categories as $category) { $category->post_count = $category->posts->count(); $category->save(); } return redirect('/backend/categories'); }
public function find($id) { return Category::with('packages')->findOrFail($id); }
public function showNewsDetail($slug, $id) { $data['category'] = Category::with('SubCategory')->orderBy('created_at', 'asc')->get(); $data['comment'] = Comment::where('news_id', $id)->get(); $data['slider'] = Slide::orderBy('created_at', 'asc')->get(); $data['sideslider'] = SideSlider::orderBy('created_at', 'asc')->get(); $data['news'] = News::findOrFail($id); $data['partner'] = Partner::orderBy('created_at', 'asc')->get(); $data['sideNews'] = News::orderBy('created_at', 'desc')->take(3)->skip(0)->get(); $data['album'] = Album::orderBy('created_at', 'asc')->take(12)->skip(0)->get(); $data['staff'] = Staff::orderBy('created_at', 'asc')->take(5)->skip(0)->get(); if ($slug != $data['news']->slug) { return Redirect::route('site.show.news.detail', $data['page']->slug, $id); } return view('site.news-detail', $data); }