public function postHomePage($id = null) { $homePage = HomePage::all(); $input = Input::all(); $rules = array(); $validator = Validator::make($input, $rules); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } $data = array('headline' => Input::get('headline'), 'text' => Input::get('text')); if (isset($input['image_names']) && $input['image_names'][0]) { $data['image'] = $input['image_names'][0]; $this->dealWithImage($data['image'], HomePage::getImagesFolderAbsolutePath()); } if ($id) { $homepage = HomePage::findOrFail($id); $homepage->update($data); } else { $homepage = HomePage::create($data); } return Redirect::back(); }