/** * Store a newly created business in storage. * * @param Request $request * @return Response */ public function store(BusinessRequest $request) { $input = $request->all(); $count = Business::count(); //Handle file upload if ($request->hasFile('businessPhoto')) { $file = $request->file('businessPhoto'); //$filename = str_replace(" ", "_", $input["name"]) . $count . '.' . $file->guessExtension(); $filename = $count . "." . $file->guessExtension(); if ($file->isValid()) { $file->move('img/', $filename); $input["imagePath"] = '/img/' . $filename; } } $input["ownerId"] = Auth::id(); Business::create($input); return redirect('/'); }