/** * Update the specified resource in storage. * * @param \App\Http\Requests\ArticlesRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(ArticlesRequest $request, $id) { $payload = array_merge($request->except('_token'), ['notification' => $request->has('notification')]); $article = Article::findOrFail($id); $article->update($payload); $article->tags()->sync($request->input('tags')); event(new ModelChanged(['articles', 'tags'])); flash()->success(trans('forum.updated')); return redirect(route('articles.index')); }
public function update($id, ArticlesRequest $request) { $article = Article::findOrFail($id); $article->update($request->all()); return redirect('articles'); }
public function update($id, ArticlesRequest $request) { $article = Article::findOrFail($id); $article_new = new Article($request->all()); $article->name = $article_new->name; $article->description = $article_new->description; $article->price = $article_new->price; $article->reference = $article_new->reference; $article->brand_id = $article_new->brand_id; $article->model_id = $article_new->model_id; $article->public = $article_new->public; $this->saveArticle($article); flash()->success('Article has been updated.'); return redirect('articles'); }
/** * Update the specified resource in storage. * * @param \App\Http\Requests\ArticlesRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(ArticlesRequest $request, $id) { $payload = array_merge($request->except('_token'), ['notification' => $request->has('notification')]); $article = Article::findOrFail($id); $article->update($payload); if ($request->has('tags')) { $article->tags()->sync($request->input('tags')); } event(new ModelChanged(['articles', 'tags'])); return $this->respondUpdated($article); }