/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function details($id) { $details = Product::with('range', 'group')->find($id); Session::flash('keywords', ''); Session::flash('title', ''); return View::make('details', compact('details')); }
public function index(Request $request) { $products = Product::with('tags', 'category', 'picture')->online()->orderBy('published_at', 'desc')->paginate(5); if ($request->ajax()) { return response()->json(View::make('partials.listProduct', array('products' => $products))->render()); } return view('front.index', compact('products')); }
public function show($id) { $product = Product::with('images')->with('manufacturer')->find($id); if (is_null($product)) { $this->code = 404; } return Response::json($product, $this->code); }
public function single($cate, $slug) { $products = Product::where('feature', true)->get()->take(4); $products1 = Product::where('feature', false)->get()->take(6); $product = Product::with(['image' => function ($q) { $q->addSelect('product_id', 'image_name'); }])->where('slug', $slug)->get(); return view('frontend.pages.product', compact('product', 'products', 'products1')); }
public function index(Request $request) { // Show a View to Load All Products in Tabular Form $query = Product::with(["category"]); $category = $request->input("categoryID"); if ($category) { $query->where("category_id", $category); } return $query->get(); }
/** * Display a listing of products under infinite scroll with pagination loading * * @param Request $request */ public function index(Request $request) { $products = Product::with('tags', 'category', 'picture')->online()->orderBy('published_at', 'desc')->paginate($this->paginate); $lastPage = $products->lastPage(); $title = "Welcome Home Page"; if ($request->ajax()) { return response()->json(['html' => view('front.blocProd', ['products' => $products, 'lastPage' => $lastPage, 'title' => $title])->render()]); } return view('front.index', compact('products', 'lastPage', 'title')); }
public function __construct() { // $productQuery = Globex::with('images')->select('id', 'title', 'description', 'price', DB::raw('0 as type')); // $adQuery = Advertisement::with('images')->select('id', 'title', 'description','price', DB::raw('1 as type')); // $motorQuery = Motor::with('images')->select('id', 'title', 'description','price', DB::raw('2 as type')); // $this->products = $adQuery->get()->merge($productQuery->get())->merge($motorQuery->get()); $this->products = Product::with('producible')->get(); $this->emirates = Emirate::all(); $this->cats = Category::whereDepth(0)->get(); }
public function product($id, $alias) { $product = Product::with('images')->findOrFail($id); if ($product->alias != $alias) { return view('errors.404'); } $new_products = Product::orderBy('order')->where('id_category', $product->id_category)->take(4)->get(); // increasing product view everytime function called DB::table('product')->where('id', $id)->increment('view', 1); return view('detail', compact('product', 'new_products')); }
public function edit($id) { $product = Product::with('categories')->find($id); $categories = Category::withDepth()->get(); $categories_id = array(); foreach ($product->categories as $category) { $categories_id[] = $category->id; } $categories = $categories->toTree(); return view('products.edit', ['product' => $product, 'categories' => $categories, 'categories_id' => $categories_id]); }
public function detail(Request $request) { $pid = $request->input('pid'); $this->_product = Product::with(['brand', 'covers', 'attrs', 'sizes'])->find($pid); if (empty($this->_product)) { return $this->failure_noexists(); } $this->subtitle($this->_product->brand->name); $this->subtitle($this->_product->title); return $this->view('m.detail'); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $product = Product::with('nutrients', 'detail')->find($id); if (!is_object($product)) { return response()->json(['error' => 'Product not found'], 404); } $data = ['id' => $product->id, 'description' => $product->description, 'food_group' => $product->food_group, 'sn' => $product->detail->scientific_name, 'cn' => $product->detail->commercial_name, 'manu' => $product->detail->manufacturer, 'nf' => $product->detail->nitrogen_to_protein_conversion_factor, 'cf' => $product->detail->carbohydrate_factor, 'ff' => $product->detail->fat_factor, 'pf' => $product->detail->protein_factor, 'r' => $product->detail->refuse_percent, 'rd' => $product->detail->refuse_description, 'nutrients' => $product->nutrients->map(function ($nutrient) { return ['id' => $nutrient->id, 'title' => $nutrient->name, 'group' => $nutrient->group, 'unit' => $nutrient->unit, 'value' => $nutrient->pivot->value]; })]; // dd(response()->json($data)); return response()->json($data); }
public function showDashboard() { $food = Product::with('category')->whereHas('category', function ($q) { $q->food(); })->enabled()->get(); $drinks = Product::with('category')->whereHas('category', function ($q) { $q->drinks(); })->enabled()->get(); $other = Product::with('category')->whereHas('category', function ($q) { $q->other(); })->enabled()->get(); $this->updateCart(); $spendings = Auth::user()->unpaidOrders->sum('total_price'); return view('dashboard', ['food' => $food, 'drinks' => $drinks, 'other' => $other, 'items' => $this->items, 'price' => $this->price, 'spendings' => $spendings]); }
/** * 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]); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { if (Auth::user()->is_admin) { $products = Product::with('category')->get(); } else { $productsAll = Product::with(['category' => function ($query) { $query->active(); }])->sell()->get(); $products = []; foreach ($productsAll as $product) { if ($product->category !== null) { $products[] = $product; } } } $view = 'index'; if (!Auth::user()->is_admin) { $view .= '_client'; } return view('products.' . $view, compact('products')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($slug, $id) { $list_color = Product::find($id)->color; $list_size = Product::find($id)->size; $size = Size::all(); $color = Color::all(); $products = Product::with(['category' => function ($querry) { $querry->addSelect('id', 'cate_name'); }, 'brand' => function ($query) { $query->addSelect(['id', 'brand_name']); }, 'image' => function ($q) { $q->addSelect('product_id', 'image_name'); }])->where('slug', $slug)->get(); foreach ($products as $product) { return view('admin.product.edit', compact('product', 'list_color', 'list_size', 'size', 'color')); } }
public function studentRentals(Request $request) { if ($request->has('q')) { $student_products = Product::with('brand')->where('active', '=', "Enable")->where('category_id', '=', $request->get('q'))->paginate(15); $categories = Category::where('active', '=', 'Enable')->get(); } else { $student_products = Product::with('brand')->where('active', '=', "Enable")->paginate(15); $categories = Category::where('active', '=', 'Enable')->get(); } return view('student-rentals', compact('student_products', 'categories')); }
public function cart() { $products = Session::get('cart.product'); $cart = []; $check = 0; $j = 0; for ($i = 0; $i < count($products); $i++) { ${"product" . $i} = Product::with('image')->find($products[$i]['id']); for ($k = 0; $k < count($products); $k++) { if (isset($cart[$k]['product']['id']) && $cart[$k]['product']['id'] === $products[$i]['id']) { $cart[$k]['quantity'] += $products[$i]['quantity']; $check = 1; } } if ($check === 0) { $j++; $cart[$j]['product'] = ${"product" . $i}; $cart[$j]['quantity'] = $products[$i]['quantity']; } $check = 0; } return view('customers.cart', compact('cart')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $product = Product::with('categories')->where('id', $id)->first(); return view('dashboard/edit_product')->with('categories', Category::get())->with("product", $product); }
/** * Show all products for administrate them. * * @return \Illuminate\Http\Response */ public function productAction() { $products = Product::with('type')->get(); return view('admin.products', compact('products')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $products = Product::with('inventory')->get(); return view('inventory.index', compact('products')); }
public function index() { $products = Product::with('tags', 'category', 'picture')->orderBy('published_at')->paginate(8); return view('admin.product', compact('products')); // var_dump('test'); }
public function showProductByCategory(Request $request, $id, $slug = '') { $products = Product::with('tags', 'category', 'picture')->where('category_id', '=', $id)->paginate(5); $lastPage = $products->lastPage(); if ($request->ajax()) { $resultat = array(); $resultat[0] = json_encode($lastPage); $resultat[1] = json_encode(View::make('front.partials.product', compact('products'))->render()); return $resultat; } return view('front.index', compact('products')); }
public function show_all() { $products = Product::with('stock')->with('customer')->get(); $tankers = Tanker::with('stock')->get(); return View('products.all')->withProducts($products)->withTankers($tankers); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $product = new Product(); $products = $product->with('categories')->orderBy('title')->paginate(20); return view('dashboard/inventory')->with('products', $products); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { //dd($id); // // $brands = Brand::all(); $categories = Category::all(); $product = Product::with('description')->find($id); $prices = $product->prices; //$mrps = Mrp::with('unit')->where('product_id', $id)->get(); //dd($mrp); $images = $product->images; $units = Unit::all(); return view('admin/product/edit', compact('product', 'categories', 'brands', 'images', 'units', 'prices')); }
public function add($id, $data) { $errorItemInRequestDup = array(); $product_code = array_get($data, 'product_code'); $qty_request = array_get($data, 'qty'); $product = Product::with(['stock' => function ($query) { $query->where('qty', '>', 0); $query->orderBy('qty', 'desc'); }, 'stock.location'])->where('code', $product_code)->first(['id']); $qty = $qty_request; foreach ($product->stock as $stock) { $qty_hold = 0; if ($qty == 0) { break; } if ($qty > $stock->qty) { $qty_hold = $stock->qty; $qty = $qty - $qty_hold; } else { if ($qty == $stock->qty) { $qty_hold = $stock->qty; $qty = $qty - $qty_hold; } else { if ($qty < $stock->qty) { $qty_hold = $qty; $qty = 0; } } } $data['requesition_id'] = $id; $data['qty'] = $qty_hold; $data['location_id'] = $stock->location_id; $data['location_name'] = $stock->location->name; $data['status'] = self::CREATE; if (!$this->checkItemInRequest($id, $product_code, $stock->location_id)) { if (self::create($data)) { $stock->qty = $stock->qty - $qty_hold; // $stock->save(); } } else { $errorItemInRequestDup[] = $product_code; } if (!empty($errorItemInRequestDup)) { flash()->error(trans('requesition_item.label.name'), trans('requesition_item.message_alert.item_duplicate_on_request')); } } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $products = \App\Product::with('inventories', 'prices')->get(); return view('reports.index', compact('products')); }
public function index() { $products = Product::with('tags', 'category', 'picture')->online()->paginate(10); $title = " Home Page"; return view('front.index', compact('products', 'title')); }
public function scrollProd(Request $request, $byType = 'bydate') { // $url = $request->url; $url = $request->getPathInfo(); $offset = $request->offset; $numberItems = $request->numberItems; // return $url; $field = 'published_at'; if ($request->order) { $order = $request->order; } else { $order = 'desc'; } if (strstr($url, 'home') !== false) { if ($byType == 'bydate') { $field = 'published_at'; // $order = 'DESC'; } elseif ($byType == 'byname') { $field = 'name'; // $order = 'ASC'; } elseif ($byType == 'byprice') { $field = 'price'; // $order = 'DESC'; } elseif ($byType == 'byscore') { $field = 'score'; // $order = 'DESC'; } $products = Product::with('tags', 'category', 'picture')->online()->orderBy($field, $order)->skip($offset)->take($numberItems)->get(); $number_DB_products = count(Product::all()); // return Response::json(View::make('front.productscroll', compact('products'))->render()); return response()->json(['data' => $number_DB_products, 'html' => view('front.productscroll', compact('products'))->render()]); } elseif (strstr($url, 'cat') !== false) { if ($byType == 'bydate') { $field = 'published_at'; // $order = 'DESC'; } elseif ($byType == 'byname') { $field = 'name'; // $order = 'ASC'; } elseif ($byType == 'byprice') { $field = 'price'; // $order = 'DESC'; } elseif ($byType == 'byscore') { $field = 'score'; // $order = 'DESC'; } preg_match('#cat/([0-9]+)#', $url, $matches); $category_id = $matches[1]; $products = Category::findOrFail($category_id)->products()->with('tags', 'category', 'picture')->online()->orderBy($field, $order)->skip($offset)->take($numberItems)->get(); $number_DB_products = count(Category::findOrFail($category_id)->products()->get()); return response()->json(['data' => $number_DB_products, 'html' => view('front.productscroll', compact('products'))->render()]); } elseif (strstr($url, 'tag') !== false) { if ($byType == 'bydate') { $field = 'published_at'; // $order = 'DESC'; } elseif ($byType == '') { $field = 'name'; // $order = 'ASC'; } elseif ($byType == 'byprice') { $field = 'price'; // $order = 'DESC'; } elseif ($byType == 'byscore') { $field = 'score'; // $order = 'DESC'; } preg_match('#tag/([0-9]+)#', $url, $matches); $tag_id = $matches[1]; $products = Tag::findOrFail($tag_id)->products()->with('tags', 'category', 'picture')->online()->orderBy($field, $order)->skip($offset)->take($numberItems)->get(); $number_DB_products = count(Tag::findOrFail($tag_id)->products()->get()); return response()->json(['data' => $number_DB_products, 'html' => view('front.productscroll', compact('products'))->render()]); } }
public function all() { return Product::with('stores')->get(); }