/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @param Category $category * @return \Illuminate\Http\Response */ public function store(Request $request, Category $category) { $this->validate($request, ['name' => 'required|unique:categories', 'slug' => 'required|unique:categories']); $input = $request->except(['_token']); $category->fill($input)->save(); return redirect('categories')->with('success', $category->name . ' category successfully added.'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $category = new Category(); $category->fill($request->all()); $image = $request->file('image'); $imageName = ""; if ($image->isValid()) { $path = public_path() . '/uploads/category/'; $imageName = str_random(32) . '.' . $image->getClientOriginalExtension(); $image->move($path, $imageName); } else { App::abort(404); } $small_image = $request->file('small_image'); $imageNamesmall = ""; if ($small_image->isValid()) { $path = public_path() . '/uploads/category/'; $imageNamesmall = str_random(32) . '.' . $small_image->getClientOriginalExtension(); $small_image->move($path, $imageNamesmall); } else { App::abort(404); } $category->image = $imageName; $category->small_image = $imageNamesmall; $category->save(); return Redirect::route('admin.category.show'); }
/** * Update the specified resource in storage. * */ public function update(Request $request, Category $category) { $category->fill($request->all()); $category->slug = str_slug($request->get('name')); $updated = $category->save(); $message = $updated ? 'Categoria actualizada' : 'Error al actualizar'; return redirect()->route('admin.category.index')->with('message', $message); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, Category $category) { $category->fill($request->all()); $category->slug = str_slug($request->get('name')); $updated = $category->save(); $message = $updated ? 'Category was updated succesfully' : 'Could not update the new category'; return redirect()->route('admin.category.index')->with('message', $message); }
/** * Store a newly created resource in storage. * * @param CreateCategoryRequest $request * @return Response */ public function store(CreateCategoryRequest $request) { $category = new Category(); $category->fill($request->all()); $category->save(); $message = trans('messages.category_created_successfully'); Flash::success($message); return redirect()->route('admin.categories.index'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, Category $category) { $this->validate($request, ['name' => 'required|max:255', 'color' => 'required']); $category->fill($request->all()); $category->slug = str_slug($request->get('name')); $updated = $category->save(); $message = $updated ? 'Categoría actualizada correctamente!' : 'La Categoría NO pudo actualizarse!'; return redirect()->route('admin.category.index')->with('message', $message); }
/** * Create a new category from request. * * @param $request input form data * @return User */ public function pushCategory($request) { $input = $request->all(); if (isset($input['name'])) { $input['slug'] = str_slug($input['name'], "-"); } $category = new Category(); $category->fill($input); $category->save(); return $category; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // $dropbox = Dropbox::createTemporaryDirectLink("/web/test.jpg"); // // return $dropbox; $this->validate($request, ['slug' => 'unique:categories,slug', 'name' => 'required', 'description' => 'required']); $category = new Category(); $category->fill($request->all()); if ($request->hasFile('featured_image')) { $file = $request->file('featured_image'); $timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString()); $name = $timestamp . '.' . $file->getClientOriginalExtension(); $path = "/web/categories/"; $dropbox = Dropbox::uploadFileFromString($path . $name, Dropbox\WriteMode::add(), file_get_contents($request->file('featured_image')->getRealPath())); $category->featured_image = $dropbox['path']; } $category->save(); Session::flash('flash_message', 'Flokkurinn var vistaður'); return redirect()->back(); }
/** * Updates Category into database * * @param Category $category * @param array $input * * @return Category */ public function update($category, $input) { $category->fill($input); $category->save(); return $category; }
/** * Update the specified category in storage. * * @param Category $category * @param CategoryRequest $request * @return Response */ public function update(Category $category, CategoryRequest $request) { $category->fill($request->all()); $category->save() ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail')); return redirect(route('admin.category.index')); }