/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $insert = $request->all(); $safeName = false; //upload image if ($file = Input::file('image')) { $fileName = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension() ?: 'png'; $folderName = '/uploads/'; $destinationPath = Config::get('app.path') . $folderName; $safeName = time() . "_" . str_random(10) . '.' . $extension; $file->move($destinationPath, $safeName); $insert['image'] = $safeName ? $folderName . $safeName : ''; } if (isset(Color::$boolean)) { foreach (color::$boolean as $field) { if (isset($insert[$field]) && $insert[$field] == "on") { $insert[$field] = 1; } } } color::create($insert); return redirect('admin/colors')->with('success', Lang::get('message.success.create')); }