/** * Display a listing of the resource. * * @return Response */ public function ApiIndexAction() { $cakes = DB::table('categories')->select('categories.id as category_id', 'categories.name as category_name', 'categories.per_pound_price', 'products.id as product_id', 'products.name as product_name', 'products.starting_pound', 'products.price', 'products.ending_pound', 'products.description as description', 'products.is_active')->leftJoin('category_product', 'category_product.category_id', '=', 'categories.id')->leftJoin('products', 'products.id', '=', 'category_product.product_id')->where('categories.parent_id', 1)->where('products.is_active', 1)->get(); $Accessories = DB::table('categories')->select('categories.id as category_id', 'categories.name as category_name', 'categories.per_pound_price', 'products.id as product_id', 'products.name as product_name', 'products.starting_pound', 'products.price', 'products.ending_pound', 'products.description as description', 'products.is_active')->leftJoin('category_product', 'category_product.category_id', '=', 'categories.id')->leftJoin('products', 'products.id', '=', 'category_product.product_id')->where('categories.parent_id', 2)->where('products.is_active', 1)->get(); $gift = DB::table('categories')->select('categories.id as category_id', 'categories.name as category_name', 'categories.per_pound_price', 'products.id as product_id', 'products.name as product_name', 'products.starting_pound', 'products.price', 'products.ending_pound', 'products.description as description', 'products.is_active')->leftJoin('category_product', 'category_product.category_id', '=', 'categories.id')->leftJoin('products', 'products.id', '=', 'category_product.product_id')->where('categories.parent_id', 3)->where('products.is_active', 1)->get(); $offers = categories::select('name as category_name', 'short_description', 'detail_description', 'per_pound_price')->where('parent_id', 4)->where('is_active', 1)->get(); $array_set = array('Cakes' => $cakes, 'Accessories' => $Accessories, 'Gift' => $gift, 'Offers' => $offers); $result = Response::json(array('result' => $array_set))->header('Content-Type', 'application/json'); return $result; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $data = categories::find($id); if ($data) { $data->delete(); return redirect()->route('parent_gift/list')->with('message', Lang::get('response.CUSTOM_MESSAGE_SUCCESS', ['message' => 'The selected gift item is delete'])); } else { return redirect()->route('parent_gift/list')->with('message', Lang::get('response.CUSTOM_MESSAGE_WARNING', ['message' => 'Whoops, looks like something went wrong . '])); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function EditAction($id) { $products = products::find($id); $n_category = categories::select('id', 'name', 'parent_id')->where('parent_id', 5)->get(); $cakes = categories::select('id', 'name')->where('parent_id', 1)->get(); return view('admin/product/cake/product_cake_edit', compact('products', 'cakes', 'n_category')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $parent_category_layout = $this->parent_category_layout; $products = products::find($id); $category = categories::select('id', 'name')->where('parent_id', 3)->get(); return view('admin/product/gift/product_gift_edit', compact('products', 'category', 'parent_category_layout')); }
public function __construct() { $this->parent_category_layout = categories::select('id', 'name')->where('parent_id', 0)->get(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function DeleteAction($id) { $this->category = categories::find($id); if ($this->category) { $this->category->delete(); return redirect()->route('category/list')->with('message', Lang::get('response.CUSTOM_MESSAGE_SUCCESS', ['message' => 'The selected category item delete'])); } return redirect()->route('category/list')->with('message', Lang::get('response.CUSTOM_MESSAGE_ALERT', ['message' => 'Whoops, looks like something went wrong.'])); }