Inheritance: extends Request
 public function store(ArticleRequest $request)
 {
     Article::create($request->all());
     session()->flash('success', 'Новость добавлена');
     // $_SESSION['success'] = 'Новость добавлена'
     return redirect()->route('main');
 }
 private function createArticle(ArticleRequest $request)
 {
     //Create an article with the attributes from the form
     $article = Auth::user()->articles()->create($request->all());
     $this->syncTags($article, $request->input('tag_list'));
     return $article;
 }
 public function update($id, ArticleRequest $request)
 {
     $article = Article::findOrFail($id);
     $article->tags()->sync($request->input('tag_list'));
     $article->update($request->all());
     return redirect('articles');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ArticleRequest $request, $id)
 {
     $article = Article::find($id);
     $article->fill($request->all());
     $article->save();
     return redirect()->route('admin.articles.index')->with('message', 'Se ha editado ' . $article->name . ' de forma correcta.');
 }
 public function update(Article $article, ArticleRequest $request)
 {
     $article->update($request->all());
     $article->tags()->sync($request->input('tag_list', []));
     \Flash::success('記事を更新しました。');
     return redirect()->route('articles.show', [$article->id]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\ArticleRequest $request, $id)
 {
     $article = Article::findOrFail($id);
     $article->update($request->all());
     $article->tags()->sync($request->get('tag_list', []));
     return redirect()->action('Goenitz\\ArticleController@index');
 }
Beispiel #7
0
 /**
  * Update the specified resource in storage.
  *
  * @param  ArticleRequest  $request
  * @param  Article $article
  * @return Response
  */
 public function update(ArticleRequest $request, Article $article)
 {
     $article->update($request->all());
     $article->tags()->sync($request->get('tag_list'));
     session()->flash('success', 'Запись ' . $request->get('title') . ' обновлена');
     return redirect()->route('article.index');
 }
 public function update(ArticleRequest $request, $id)
 {
     $article = Article::findOrFail($id);
     $article->update($request->all());
     session()->flash('flash_message', 'Article Updated!');
     return redirect('/articles');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  ArticleRequest  $request
  * @param  Article  $article
  * @return Response
  */
 public function update(ArticleRequest $request, Article $article)
 {
     $article->update($request->all());
     $article->tags()->sync($request->input('tag_list', []));
     Flash::success(trans('message.entity_updated', ['entity' => trans('models.article')]));
     return redirect()->route('admin.articles.edit', ['id' => $article->id]);
 }
 public function update(Article $article, ArticleRequest $request)
 {
     // $article = Article::findOrFail($id);
     $article->update($request->all());
     \Session::flash('flash_message', '記事を更新しました。');
     // return redirect(url('articles', [$article->id]));
     return redirect()->route('articles.show', [$article->id]);
 }
 public function store(ArticleRequest $request)
 {
     //Automatic Validation because of App\Http\Requests\CreateArticleRequest
     $article = new Article($request->all());
     \Auth::user()->articles()->save($article);
     //Article::create($request->all());
     return redirect('articles');
 }
 public function update(Article $article, Requests\ArticleRequest $request)
 {
     //type hinting ArticleRequest lets us do validation
     //$article = Article::findOrFail($id);
     $article->update($request->all());
     $article->tags()->sync($request->input('tag_list'));
     return redirect('articles');
 }
 public function update(Requests\ArticleRequest $request, $id)
 {
     $article = Article::findOrFail($id);
     $article->update($request->all());
     $article->tags()->sync($request->input('tag_list'));
     // sync - delete old & add new tags
     return redirect('articles');
 }
 private function createArticle(Requests\ArticleRequest $request)
 {
     $article = new Article($request->all());
     $article = Auth::user()->articles()->save($article);
     $tagIds = $request->input('tag_list');
     $this->syncTags($article, $tagIds);
     return $article;
 }
 private function createArticle(ArticleRequest $request)
 {
     $article = \Auth::user()->articles()->create($request->all());
     $tagIds = $request->input("taglist");
     //returns array of submitted ids of tags
     $article->tags()->attach($tagIds);
     return $article;
 }
 private function createArticle(ArticleRequest $request)
 {
     $article = new Article($request->all());
     $article_id = Auth::user()->articles()->save($article);
     //returns id of article
     $this->syncTags($article_id, $request->input('tag_list'));
     return $article_id;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param Article $article
  * @param ArticleRequest $request
  * @return \Illuminate\Http\Response
  */
 public function update(Article $article, ArticleRequest $request)
 {
     $article->update($request->all());
     if ($tags = $request->get('tag_list')) {
         $article->tags()->sync($tags);
     }
     flash()->success('Article has been edited!');
     return Redirect::back();
 }
 public function update(ArticleRequest $request, Article $article)
 {
     $article->update($request->all());
     session()->flash('flash_message', 'Article was updated with success');
     if (Request::wantsJson()) {
         return $article;
     }
     return redirect('articles');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, ArticleRequest $request)
 {
     $article = Article::findOrFail($id);
     $article->fill($request->all());
     $article->modified_by = Auth::user()->id;
     $article->save();
     flash()->success('Article Updated');
     return redirect('articles');
 }
 public function newArticle(ArticleRequest $request)
 {
     $user = Auth::user();
     $article = new Article($request->all());
     $article->user_id = $user->id;
     $article->save();
     Auth::user()->articles()->save($article);
     $user->save();
 }
Beispiel #21
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(ArticleRequest $request, Article $article)
 {
     if ($article->update($request->all())) {
         Flash::success('修改成功!');
         return View::make($this->getView('edit'))->withArticle($article);
     } else {
         Flash::error('修改失败!');
         return Redirect::back()->withInput();
     }
 }
Beispiel #22
0
 public function update($id, ArticleRequest $request)
 {
     if (\Auth::guest()) {
         return redirect('article');
     }
     $article = Article::findOrFail($id);
     $article['updated_at'] = Carbon::now('Asia/Shanghai');
     $article->update($request->all());
     return redirect('article');
 }
 /**
  * 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');
 }
 public function update(Article $article, ArticleRequest $request)
 {
     $this->authorize('update', $article);
     $requests = $request->all();
     $this->articles->syncTags($article, $request->tag_list);
     $requests['comment_status'] = $request->comment_status ? $request->comment_status : 0;
     $requests['excerpt'] = $requests['excerpt'] ? $requests['excerpt'] : mb_content_filter_cut($requests['body']);
     $article->update($requests);
     Auth::user()->histories()->create(['type' => 'article', 'content' => '修改文章《<a href="/article/' . $article->id . '" target="_blank">' . $article->title . '</a>》']);
     flash()->message('文章修改成功!');
     return redirect('article/' . $article->id);
 }
 public function store(ArticleRequest $request)
 {
     //Automatic Validation because of App\Http\Requests\CreateArticleRequest
     $article = new Article($request->all());
     \Auth::user()->articles()->save($article);
     //Article::create($request->all());
     $tagIds = $request->input('tag_list');
     $article->tags()->attach($tagIds);
     \Session::flash('flash_message', 'Your article has been created!');
     \Session::flash('flash_message_important', true);
     return redirect('articles');
 }
 public function update(Article $article, ArticleRequest $request)
 {
     $article->update($request->all());
     $article->articleImages()->delete();
     if (count($request->eyecatch) > 0) {
         foreach ($request->eyecatch as $key => $eyecatch) {
             $articleImage = new ArticleImage(['eyecatch' => $eyecatch]);
             $article->articleImages()->save($articleImage);
         }
     }
     $article->tags()->sync($request->input('tag_list', []));
     \Flash::success('記事を更新しました。');
     // return redirect()->route('articles.show', [$article->id]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  CreateArticleRequest  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ArticleRequest $request)
 {
     $article = new Article($request->all());
     $article->setImage($request);
     $article->setThumbnail($request);
     $article->setPublishedAtAttribute(Carbon::now());
     Auth::user()->articles()->save($article);
     $article->tags()->attach($request->input('tag_list'));
     // sending back with message
     Session::flash('success', 'Created Article Successfully');
     // create the new article;
     // return to the index
     return Redirect('articles')->with('message', 'Article created');
 }
Beispiel #28
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');
 }
Beispiel #29
0
 /**
  * Cập nhật bài viết
  *
  * @param  Article  $article
  * @return Response
  */
 public function update(Article $article, ArticleRequest $request, ImageInterface $image)
 {
     $data = $request->all();
     if ($request->hasFile('image')) {
         // Trước hết cần xóa các file ảnh cũ nếu có
         if ($article->image) {
             \File::delete(public_path(config("image.paths") . 'articles/large' . $article->image));
             \File::delete(public_path(config("image.paths") . 'articles/medium' . $article->image));
             \File::delete(public_path(config("image.paths") . 'articles/small' . $article->image));
         }
         $image->init($request, 'articles')->save('large')->save('medium')->save('small');
         $data = array_replace($data, ['image' => $image->name]);
     }
     $article->update($data);
     $article->syncTags($request->input('tag_list', []));
     return redirect('admin/article')->with('flash_message', config('blog.message.updated'));
 }
 public function update($id, ArticleRequest $request)
 {
     $article = Article::findOrFail($id);
     $article->update($request->all());
     $files = Input::file('images');
     $uploads = '/uploads/';
     $path = public_path() . $uploads;
     foreach ($files as $file) {
         if (empty($file)) {
             continue;
         }
         $fileName = $file->getClientOriginalName();
         $file->move($path, $fileName);
         (new Image(['image' => $uploads . $fileName, 'article_id' => $article->id]))->save();
     }
     return redirect('articles');
 }