public function search(Request $request) { $data = Category::with('products.brands', 'products.sizes', 'products.photos')->where('name', 'LIKE', '%' . $request->input('q') . '%')->get(); if ($data->count() > 0) { return Response::json(['error' => false, 'count' => $data->count(), 'data' => ['categories' => $data, 'base_url' => url()]]); } else { return Response::json(['error' => true, 'message' => 'No data category found']); } }
public function index() { $this->data['css_assets'] = Assets::load('css', ['lib-bootstrap', 'style', 'font-awesome', 'font-awesome-min', 'flexslider', 'color-schemes-core', 'color-schemes-turquoise', 'jquery-parallax', 'bootstrap-responsive', 'font-family']); $this->data['js_assets'] = Assets::load('js', ['jquery', 'jquery-ui', 'jquery-easing', 'bootstrap-min-lib', 'jquery-isotope', 'jquery-flexslider', 'jquery.elevatezoom', 'jquery-sharrre', 'jquery-gmap3', 'imagesloaded', 'la_boutique', 'jquery-cookie', 'jquery-parallax-lib']); $this->data['title'] = 'Home'; $this->data['category'] = Category::get(); $this->data['product'] = Product::where('status', 'publish')->orderBy('created_at', 'DESC')->limit(5)->get(); $this->data['sold'] = Product::where('status', 'publish')->orderBy('sold', 'DESC')->limit(5)->get(); $this->data['banner'] = Option::where('meta_key', 'banner_home')->first(); return view('main_layout')->with('data', $this->data)->nest('content', 'home', array('data' => $this->data)); }
public function subproduct($slug, $subcategory) { $this->data['css_assets'] = Assets::load('css', ['lib-bootstrap', 'style', 'font-awesome', 'font-awesome-min', 'flexslider', 'color-schemes-core', 'color-schemes-turquoise', 'jquery-parallax', 'bootstrap-responsive', 'font-family']); $this->data['js_assets'] = Assets::load('js', ['jquery', 'jquery-ui', 'jquery-easing', 'bootstrap-min-lib', 'jquery-isotope', 'jquery-flexslider', 'jquery.elevatezoom', 'jquery-sharrre', 'jquery-gmap3', 'imagesloaded', 'la_boutique', 'jquery-cookie', 'jquery-parallax-lib']); $this->data['slugcategory'] = Category::where('slug', $slug)->first(); $this->data['slugsubcategory'] = Subcategory::where('slug', $subcategory)->first(); //$this->data['banner'] = Option::where('meta_key','banner_'.$slug)->first(); //$this->data['title'] = $this->data['slugsubcategory']->name; if ($this->data['slugcategory'] == NULL || $this->data['slugsubcategory'] == NULL) { $this->data['title'] = '404 - not found'; $this->data['message'] = 'Subcategory that you looking for is not found or has been removed'; return view('main_layout')->with('data', $this->data)->nest('content', 'error/404_product', array('data' => $this->data)); } else { $this->data['banner'] = Option::where('meta_key', 'banner_' . $slug)->first(); $this->data['title'] = ucwords($this->data['slugcategory']->name) . ' - ' . $this->data['slugsubcategory']->subname; return view('main_layout')->with('data', $this->data)->nest('content', 'product/product', array('data' => $this->data)); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $category = Category::findOrFail($id); $category->delete(); return redirect('admin/categories')->with('message', 'Category successfully delete!'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { //$menus = User::find(Auth::user()->id)->category()->get(); $menus = Category::all(); return view('layouts.layout', compact('menus')); }
public function delete_category($id) { Category::find($id)->delete(); return redirect('master/setting/category/list'); }
public function category_banner(Request $request) { $this->data['category'] = Category::where('slug', $request->name)->first(); $this->data['title'] = $this->data['category']->name; $this->data['banner'] = Option::where('meta_key', 'banner_' . $request->name)->first(); return view('admin/setting/banner_category_content')->with('data', $this->data); }
public function delete($id) { $product = Product::find($id); $category = Category::where('id', $product->category_id)->first(); $inOrder = OrderDetail::where('product_id', $id)->where('review', null)->get(); $reviews = Reviews::where('product_id', $id)->get(); $subcategory = Subcategory::where('id', $product->subcategory_id)->first(); if (!$product) { return redirect('master/produk/list')->with('error', 'Data tidak ada'); } else { $image = unserialize($product->image); $path = base_path() . '/storage/photo_product/'; if (count($inOrder) > 0) { $product->status = 'unactive'; if ($product->save()) { return redirect('master/produk/list')->with('success', 'Produk tidak bisa di hapus karena masih dalam order, produk sementara di non aktifkan'); } else { return redirect('master/produk/list')->with('error', '404'); } } elseif (count($inOrder) == 0) { if ($product->delete()) { foreach ($reviews as $review) { $reviews->delete(); } foreach ($inOrder as $order_product) { foreach ($order_product as $orders) { $PaymentConfirmation = PaymentConfirmation::where('order_id', $orders->id)->first(); $PaymentConfirmation->delete(); } $orders = Order::where('id', $order_product->order_id)->get(); $orders->delete(); } $total_product = $category->total_product - 1; $category->total_product = $total_product; $category->save(); $total_subcategory = $subcategory->total_product - 1; $subcategory->total_product = $total_subcategory; $subcategory->save(); if (!$image == NULL) { foreach ($image as $image) { File::delete($path . $image); } } return redirect('master/produk/list')->with('success', 'Produk ' . $product->name . ' Berhasil Dihapus'); } else { return redirect('master/produk/list')->with('error', '404'); } } } }