/** * Store a newly created resource in storage. * * @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException * @return Response */ public function store(ArticleRequest $request) { $this->request = $request; $this->getCategory(); // everything was validated by ArticleRequest, ready to save $input = $request->except('_token'); $article = Article::create($input); // this should be the url to the article $url = '/' . $this->category->path . '/' . $article->slug; if ($article) { if ($request->ajax()) { return ['response' => 'success', 'next' => $url]; } return redirect($url)->with('success', 'Article saved.'); } return back()->withInput(); }