validate($request, [ 'icon' => 'required|image', ]); $path = $request->file('icon')->store('public/icons'); $response['filename'] = pathinfo($path)['basename']; return response()->json($response, 201); } /** * delete an icon * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function delete($icon) { Storage::delete('public/icons/' . $icon); return response()->json(null, 204); } }