/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(BlogRequest $request, $id) { // $blog = Blog::findOrfail($id); $blog->update($request->all()); return redirect('blogs'); }
public function update(Blog $blog, BlogRequest $request) { $blog->update($request->all()); $this->syncTags($blog, $request->input('tag_list')); flash()->overlay('Your blog has been updated!', 'Good Job'); return redirect('blogs'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(BlogRequest $request, Blog $blog) { if ($request->hasFile('image')) { $file = $request->file('image'); $filename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension() ?: 'png'; $folderName = '/uploads/blog/'; $picture = str_random(10) . '.' . $extension; $blog->image = $picture; } if ($request->hasFile('image')) { $destinationPath = public_path() . $folderName; $request->file('image')->move($destinationPath, $picture); } $blog->retag($request['tags']); if ($blog->update($request->except('image', '_method', 'tags'))) { return redirect('admin/blog')->with('success', trans('blog/message.success.update')); } else { return Redirect::route('admin/blog')->withInput()->with('error', trans('blog/message.error.update')); } }
/** * Update the post in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update($id, Requests\BlogRequest $request) { if (\Auth::guest()) { return redirect('/'); } $blog = Blog::findorFail($id); $blog->update($request->all()); session()->flash('flash_message', 'blog Successfully Saved!'); return redirect('blog/' . $blog->slug . ''); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function postEdit(BlogRequest $request, Blog $blog) { $picture = ""; if ($request->hasFile('image')) { $file = $request->file('image'); $filename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension() ?: 'png'; $folderName = '/uploads/blog/'; $picture = str_random(10) . '.' . $extension; $blog->image = $picture; } $blog->update($request->except('image', '_method', 'tags')); if ($request->hasFile('image')) { $destinationPath = public_path() . $folderName; $request->file('image')->move($destinationPath, $picture); } $blog->retag($request['tags']); return redirect('admin/blog'); }
/** * @param Blog $blog * @param BlogRequest $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * * This function will save the update to DB. */ public function update(Blog $blog, BlogRequest $request) { $blog->update($request->all()); return redirect('blog'); }
private function saveImage(Blog $blog, BlogRequest $request) { if ($request->file('image')) { $imageName = $blog->id . '.' . $request->file('image')->getClientOriginalExtension(); $newExt = 'images/catalog/' . $imageName; $img = Image::make($request->file('image'))->orientate()->heighten(300); $img->save(public_path($newExt)); } }