/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input. $category = Category::findOrFail($id); $category->update($request->all()); return redirect('category'); }
/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update($id, Request $request) { $category = Category::findOrFail($id); $category->update($request->all()); Session::flash('flash_message', 'Category updated!'); return redirect('admin/category'); }
/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update(CategoryRequest $request, $id) { $category = Category::findOrFail($id); $category->update($request->all()); \Cache::tags('categories')->flush(); return redirect('admin/categories/index'); }
/** * Display the products of the specified category. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $category = Category::findOrFail($id); $categoryIdNav = $category->id; $products = $category->products()->latest()->available()->paginate(12); return view('category.show', compact('products', 'categoryIdNav')); }
public function update(UpdateCategoryRequest $request, $id) { $category = Category::findOrFail($id); $category->update($request->all()); session()->flash('flash_message', message('user_successfully_updated_category')); return redirect('/categories/manage'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CategoryRequest $request, $id) { $category = Category::findOrFail($id); $category->update($request->all()); flash('Category has been updated'); return Redirect::back(); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // bind article $router->model('article', 'App\\Article'); $router->bind('admin.article', function ($id) { return \App\Article::findOrFail($id); }); // bind category $router->model('category', 'App\\Category'); $router->bind('admin.category', function ($id) { return \App\Category::findOrFail($id); }); // bind language $router->model('language', 'App\\Language'); $router->bind('admin.language', function ($id) { return \App\Language::findOrFail($id); }); // bind language $router->model('page', 'App\\Page'); $router->bind('admin.page', function ($id) { return \App\Page::findOrFail($id); }); // bind setting $router->model('setting', 'App\\Setting'); $router->bind('admin.setting', function ($id) { return \App\Setting::findOrFail($id); }); // bind user $router->model('user', 'App\\User'); $router->bind('admin.user', function ($id) { return \App\User::findOrFail($id); }); parent::boot($router); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(CategoryRequest $request) { $category = Category::findOrFail($request->get('id')); $category->name = $request->get('name'); $category->save(); return \Redirect::route('index-category')->with('message', 'Record has been Saved'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $category = Category::findOrFail($id); $category->delete(); flash()->success('Category Deleted!'); return redirect()->route('categories.index'); }
/** * Update the specified category in storage. * @param UpdateCategoryRequest|Request $request * * @param int $id */ public function update($id, UpdateCategoryRequest $request) { $category = Category::findOrFail($id); $request = $this->saveFiles($request); $category->update($request->all()); return redirect()->route('admin.category.index'); }
public function sort($id, Request $request) { $order = $request->order; $category = Category::findOrFail($id); $products = Product::where('category_id', '=', $id); switch ($order) { case "1": $products = $products->orderByName()->get(); break; case "2": $products = $products->orderByName("DESC")->get(); break; case "3": $products = $products->orderByPrice('DESC')->get(); break; case "4": $products = $products->orderByPrice()->get(); break; default: $products = $products->get(); break; } if (!$this->auth->guest()) { foreach ($products as $product) { $product->discountPrice(); } } else { $products = $products->filter(function ($products) { return !$products->isOffer(); }); } return View::make('category.product', array('products' => $products, 'actualCategory' => $category, 'selected' => $order)); }
public function showProductByCategory($id, $slug = '') { $category = Category::findOrFail($id); $products = $category->products()->with('tags', 'category', 'picture')->paginate(5); $title = " Welcome category page {$category->title}"; return view('front.category', compact('products', 'title')); }
public function category($id) { $categories = $this->categories(); $articles = Category::findOrFail($id)->articles()->orderBy('id', 'desc')->paginate(10); $category = Category::findOrFail($id); return view('home.category', compact('categories', 'articles', 'category')); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(QuizRequest $request) { $cat = Category::findOrFail($request->input('cat_list')); $quiz = $cat->quizzes()->create($request->all()); flash()->success('New Quiz has been created!'); return redirect('quizzes'); }
public function updateCategories(Request $request) { foreach ($request->all() as $id => $data) { if ($id !== '_token') { if ($data['type'] == 'remove' && $id >= 1) { $found = Category::findOrFail($id); if ($found->products->isEmpty()) { $found->delete(); } } else { if ($data['name'] !== '' && $data['type'] !== '') { if ($id >= 1) { $found = Category::findOrFail($id); } else { $found = new Category(); } $found->name = $data['name']; $found->type = $data['type']; $found->save(); } } } } return redirect()->route('categories.index'); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $categories = Category::all(); $category = Category::findOrFail($id); $posts = Post::where('category_id', $category->id)->orderBy('created_at', 'DESC')->paginate(4); return view('categories.show')->with('categories', $categories)->with('posts', $posts)->with('title', $category->title); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $category = Category::findOrFail($id); $category->delete(); Flash::success('Category deleted!'); return redirect('admin/category'); }
public function delete($id) { $category = Category::findOrFail($id); $category->delete(); session()->flash('flash_message', 'You have been deleted 1 category!'); return redirect()->route('settings.category'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $category = Category::findOrFail($id); $this->validate($request, ['title' => 'required|string|max:255|unique:categories,title,' . $category->id, 'parent_id' => 'exists:categories,id']); $category->update($request->all()); \Flash::success('Category updated.'); return redirect()->route('categories.index'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $this->validate($request, ['name' => 'required|unique:categories,id,' . $id . '|max:255', 'description' => 'required|min:255']); $category = Category::findOrFail($id); $category->update($request->all()); flash()->success('Success!', 'Category has been updated!'); return redirect('categories'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $product = Product::findOrFail($id); $categories = Category::lists('name', 'id'); $category = Category::findOrFail($product->category_id); $images = $this->getImages(); return view('product.edit', compact('categories', 'category', 'product', 'images')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $product_size = ProductSize::findOrFail($id); $product = Product::findOrFail($product_size->product_id); $category = Category::findOrFail($product->category_id); $extras = Extra::where('product_size_id', '=', $id)->get(); return view('product_size.show', compact('product_size', 'product', 'category', 'extras')); }
public function sub(Request $request) { /** * changed By Dara on 16/11/2015 * if the category_id ==0 then dont search for its subCategory */ return Category::findOrFail($request->input('category_id'))->getDescendants(); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $category = Category::findOrFail($id); if ($category->update($request->all())) { return $category; } else { return response('COULD NOT SAVE', 500); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $extra = Extra::findOrFail($id); $product_size = ProductSize::findOrFail($extra->product_size_id); $product = Product::findOrFail($product_size->product_id); $category = Category::findOrFail($product->category_id); $product_sizes = ProductSize::where('product_id', '=', $product->id)->lists('size', 'id'); return view('extra.edit', compact('product_size', 'product', 'category', 'product_sizes', 'extra')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { try { $category = Category::findOrFail($id); } catch (ModelNotFoundException $ex) { return redirect()->route('admin.categories.index')->withMessage('<b>Error!</b> category not found')->withClass('danger'); } return view('admin.categories.edit', compact('category')); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $this->validate($request, ['name' => 'required']); $category = Category::findOrFail($id); $category->status = $request->has('status') ? true : false; $category->update($request->all()); message()->success('Successfully updated Category'); return ['location' => action('CategoriesController@index')]; }
public function update(Request $request, $id) { $category = Category::findOrFail($id); $category->name = $request->name; $category->slug = $request->slug; $category->parent = $request->parent; $category->description = $request->description; $category->save(); }
/** * Handle order */ public function orderHandle() { $datas = Input::except('_token'); foreach ($datas as $id => $weight) { $this->Category->findOrFail($id)->update(['weight' => $weight]); } Flash::info('app.Operation complete'); return redirect()->back(); }
/** * */ public function scopeSelectCategory() { if (Input::has('category_id')) { $categoryId = Category::findOrFail(Input::get('category_id'))->childCategorys->modelKeys(); return $this->builder = $this->builder->where('category_id', '=', Input::get('category_id'))->orWhereIn('category_id', $categoryId); } else { return $this->builder->where('type_id', Content::TYPE_TOPIC); } }