/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['title' => 'required', 'content' => 'required', 'category_id' => 'required|numeric', 'status' => 'required']); $content = new Content($request->all()); $category = \App\Category::findOrFail($request->input('category_id')); $content->createdBy()->associate(Auth::user()); $content->updatedBy()->associate(Auth::user()); $content->category()->associate($category); $content->thumb_images = $request->input('images'); $content->thumb_images = str_replace('source', 'thumbs', $content->thumb_images); $content->save(); Session::flash('flash_message', 'Content successfully added!'); return redirect()->back(); }