/**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(ArticleRequest $request, Article $article)
 {
     $input = $request->all();
     $article->update(['title' => $input['title'], 'body' => $input['body'], 'excerpt' => $input['excerpt']]);
     if ($request->ajax() || $request->wantsJson()) {
         return new JsonResponse($article);
     }
     flash()->success('aggiornato con successo!');
     return redirect('articles');
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(ArticleRequest $request, Article $article)
 {
     $input = $request->all();
     $article->update(['title' => $input['title'], 'body' => $input['body'], 'codice_prodotto' => $input['codice_prodotto'], 'disponibile' => $input['disponibile'], 'prezzo' => $input['prezzo'], 'categoria' => $input['categoria']]);
     if ($request->file('immagine')) {
         $imageName = $article->id . '.' . $request->file('immagine')->getClientOriginalExtension();
         $request->file('immagine')->move(base_path() . '/public/images/catalog/', $imageName);
         $article->update(['immagine' => $imageName]);
     }
     if ($request->ajax() || $request->wantsJson()) {
         return new JsonResponse($article);
     }
     flash()->success('aggiornato con successo!');
     return redirect('articles');
 }