/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validation = $this->validation($request->all()); if ($validation->fails()) { return redirect()->back()->withInput()->withErrors($validation); } if (!($request->file('artwork')->isValid() || $request->file('signature')->isValid())) { return redirect()->back()->withInput()->withErrors(['there went something wrong while uploading the pictures.']); } $auction = new Art(); $auction->fill($request->all()); $auction->slug = $this->slugify($request->input('title')); $auction->description_nl = $request->input('description'); $auction->description_en = $request->input('description'); $auction->condition_nl = $request->input('condition'); $auction->condition_en = $request->input('condition'); $auction->user_id = 1; $auction->artist_id = 1; $auction->style_id = 1; $auction->save(); //store the images $this->storeImage($auction, $request->file('artwork'), true); $this->storeImage($auction, $request->file('signature'), false); //store optional image if is set if ($request->file('optional_image')) { $this->storeImage($auction, $request->file('optional_image'), false); } return redirect()->route('art.index')->withSuccess('successfully made a new auction'); }