/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(PhotoRequest $request) { if ($request->hasFile('photo')) { if ($request->file('photo')->isValid()) { $photoName = md5(Carbon::now()) . "." . $request->file('photo')->getClientOriginalExtension(); $request->file('photo')->move(public_path('images'), $photoName); $photo = Photo::create(['url' => $photoName, 'gallery' => 1]); return back()->withNotification('Success! Image has been added to gallery.')->withType('success'); } return back()->withNotification('Error! Something went wrong.')->withType('danger'); } return back()->withNotification('Error! Something went wrong.')->withType('danger'); }