public function run() { DB::table('home_page')->delete(); $success = File::cleanDirectory($this->getImagesPath()); File::put($this->getImagesPath() . '.gitignore', File::get(public_path() . '/../app/storage/cache/.gitignore')); HomePage::create(['headline' => "Industrial Legacy", 'text' => 'RUSTIC DETAILS. MODERN EDGE. REFINED LIVING IN COURT SQUARE. <br> 1 - 4 BEDROOM HOMES FROM $615K. PENTHOUSES PRICED UPON REQUEST.', 'subtext' => 'CHILDREN\'S PLAYROOM, LOUNGE, LIBRARY, GYM, TERRACE AND PARKING', 'image' => $this->copyImage(public_path() . '/backup_images/building/building.jpg')]); }
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(); }