public static function updateLease($id, $leaseId) { $params = $_POST; if (parent::logged_in_user_is_landlord_of($id)) { $lease = new Lease(array('id' => $leaseId, 'tenant' => $params['tenant'], 'tenant_email' => $params['tenant_email'], 'rent' => $params['rent'], 'start_date' => $params['start_date'], 'end_date' => $params['end_date'], 'rental_unit' => $params['rental_unit'])); if ($lease->validate()) { $lease->update(); Amenity::update_amenities_of(Amenity::LEASE, $leaseId, $params); Redirect::to('/units/' . $params['rental_unit'], array('message' => 'lease updated')); } else { $errors = array_values($lease->errors()); Redirect::to('/units/' . $params['rental_unit'] . '/leases/' . $leaseId . '/edit', array('errors' => $errors, 'input' => $params, 'unit' => RentalUnit::find($params['rental_unit']))); } } Redirect::to('/units/' . $params['rental_unit'], array('message' => 'insufficient rights')); }
public static function updateUnit($id) { if (self::logged_in_user_is_landlord_of($id)) { $params = $_POST; $unit = RentalUnit::find($id); $unit->description_title = $params['description_title']; $unit->description = $params['description']; $unit->advertised_rent = $params['advertised_rent']; if ($unit->validate()) { $unit->updateUnit(); } else { $errors = array_values($unit->errors()); Redirect::to('/units/' . $unit->id, array('errors' => $errors)); } Amenity::update_amenities_of(Amenity::RENTAL_UNIT, $id, $params); Redirect::to('/units/' . $unit->id, array('message' => 'rental unit updated')); } Redirect::to('/units/' . $id, array('message' => 'insufficient rights')); }