public function postEdit($id, EstateAdBindingModel $estate) { if ($this->estate->estateExist($id) !== 1) { Session::setError('The estate id is invalid'); Redirect::back(); } $estate->images = $this->reArrayFiles($estate->images); $validator = $this->validateEstateAd(new Validation(), $estate); if (!$validator->validate()) { Session::setError($validator->getErrors()); Redirect::back(); } $imageId = $this->estate->getMainImageId($id)['main_image_id']; if (isset($estate->main_image) && !empty($estate->main_image['name'])) { if (empty($imageId)) { $imageId = $this->addEstateMainImage($estate); } else { Session::setError('You have to delete the existed main image'); Redirect::back(); } } $this->estate->edit($id, $estate->location, $estate->price, $estate->area, $estate->floor, $estate->is_furnished, $estate->description, $estate->phone, $estate->category_id, $estate->city_id, $estate->ad_type, $imageId); $this->addEstateAdditionalImages($id, $estate); Session::setMessage('Estate Ad is edited successfully'); Redirect::to(''); }
public function addToFavourites($id) { if ($this->estate->estateExist($id) !== 1) { Session::setError('The estate id is invalid'); Redirect::back(); } if (Auth::isAuth()) { $this->user->addEstateToFavourites(Auth::getUserId(), $id); } else { $favourites = Session::get('favourites') ? Session::get('favourites') : array(); $favourites[] = $id; Session::set('favourites', $favourites); } Session::setMessage('Added to favourites'); Redirect::back(); }