/** * Return the categories with their products * * @return mixed */ public function getProductsOrderedByCategory() { 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(); }
public function getCategoriesWithProducts() { $categories = Category::with('products')->get(); if ($categories->isEmpty()) { return $this->responseNotFound(['Categories is empty']); } return $this->responseOk($categories); }
public function get($month, $year) { $this->month = $month; $this->year = $year; return Category::with(array('items' => function ($q) { $q->where(DB::raw('MONTH(items.created_at)'), '=', $this->month)->where(DB::raw('YEAR(items.created_at)'), '=', $this->year); }))->get(); }
private function get_categories() { $categories = Cache::rememberForever('wechat_index_categories_wfh', function () { $categories = Category::with('children')->where('parent_id', '0')->orderBy('parent_id', 'asc')->orderBy('sort_order', 'asc')->orderBy('id', 'asc')->get(); return $categories; }); return $categories; }
private function get_categories() { $categories = Cache::rememberForever('wyshop_admin_category_categories', function () { $categories = Category::with('goods')->orderBy('parent_id', 'asc')->orderBy('sort_order', 'asc')->orderBy('id', 'asc')->get(); return tree($categories); }); return $categories; }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $categories = Category::with('translations')->get(); $amenities = Tag::with('translations')->get(); return view('dashboard.spaces.create', compact('categories', 'amenities')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $this->validate($request, ['title' => 'required|min:3', 'description' => 'min:3']); $category = Category::find($id); $old_title = $category->title; if ($category) { \DB::transaction(function () use($request, $category) { $category->translate()->title = $request->get('title'); $category->translate()->description = $request->get('description'); $category->parent_id = $request->get('parent_id'); return $category->save(); }); } session()->flash('message', ['success', "Your category has been updated from <strong><i>" . $old_title . "</i></strong> to <strong><i>" . $category->title . "</i></strong>, successfully!"]); $categories = Category::with('translations')->paginate(10); return view('dashboard.categories.index', compact('categories')); }
public function getDataViewComponent($categoryID) { $category = Category::with('accessories.company')->find($categoryID); $category_assets = $category->components; if (Input::has('search')) { $category_assets = $category_assets->TextSearch(e(Input::get('search'))); } if (Input::has('offset')) { $offset = e(Input::get('offset')); } else { $offset = 0; } if (Input::has('limit')) { $limit = e(Input::get('limit')); } else { $limit = 50; } $order = Input::get('order') === 'asc' ? 'asc' : 'desc'; $allowed_columns = ['id', 'name', 'serial', 'asset_tag']; $sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at'; $count = $category_assets->count(); $rows = array(); foreach ($category_assets as $asset) { $actions = ''; $inout = ''; if ($asset->deleted_at == '') { $actions = '<div style=" white-space: nowrap;"><a href="' . route('update/component', $asset->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> <a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/component', $asset->id) . '" data-content="' . trans('admin/hardware/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($asset->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></div>'; } $rows[] = array('id' => $asset->id, 'name' => (string) link_to_route('view/accessory', $asset->name, [$asset->id]), 'actions' => $actions, 'companyName' => Company::getName($asset)); } $data = array('total' => $count, 'rows' => $rows); return $data; }
public function viewTrash() { $data = Category::with('subcategories')->onlyTrashed()->get(); return \Response::json($data); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $getAllCategories = Category::with('subCatLevel1')->get(); //dd($getAllCategories); return view('categorylist')->with(array('allCategories' => $getAllCategories)); }
/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function edit($id) { $venue = Venue::where('id', $id)->first(); $categories = Category::with('translations')->get(); $amenities = Tag::with('translations')->get(); return view('dashboard.venues.edit', compact('venue', 'categories', 'amenities')); }
public function getPriceListInCurrentCategory(ProductCart $productCart, $categoryName, $depoId) { $category = Category::with('product.price.stantion.train_road')->where('category', $categoryName)->first(); $stantion = Stantion::where('id', $depoId)->first(); $depoName = $stantion->stantion_name; $productsArr = []; if (Auth::guest()) { $userID = 0; } else { $userID = Auth::user()->id; } foreach ($category->product as $product) { foreach ($product->price as $price) { if ($price->price > 0 && $price->amount > 0) { $productsArr[$price->stantion[0]->train_road->tr_name][$price->stantion[0]->stantion_name][] = ['name' => $product->name, 'product_id' => $product->id, 'depo_id' => $price->stantion[0]->id, 'price_id' => $price->id, 'article' => $product->article, 'description' => $product->description, 'price' => $price->price, 'amount' => $price->amount]; } } } $sumAndCount = $this->getGeneralViewOfCart($productCart); return view('purchases.trainCarPriceListInCurrentCategory', ['p' => 'purchases', 'productsArr' => $productsArr, 'category' => $categoryName, 'userID' => $userID, 'productsCount' => $sumAndCount['productsCount'], 'productsSum' => $sumAndCount['productsSum'], 'whatDepoIdWeAre' => $depoId, 'whatDepoNameWeAre' => $depoName]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $categories = Category::with('user')->get(); return view('admin.categories.index', compact('categories')); }