public function postTerracePage($id = null) { $input = Input::all(); $data = array('headline' => $input['headline'], 'text' => $input['text']); if (isset($input['image_names']) && $input['image_names'][0]) { $data['image_name'] = $input['image_names'][0]; $this->dealWithImage($data['image_name'], TerraceLivingPage::getImagesFolderAbsolutePath()); } if ($id) { $contactPage = TerraceLivingPage::findOrFail($id); $contactPage->text = $input['text']; $contactPage->headline = $input['headline']; $contactPage->save(); $contactPage->update($data); } else { $contactPage = TerraceLivingPage::create($data); } return Redirect::back(); }