/** * Gets all rooms to choice list. * * @access private * @param Silex\Application $app Silex application * @return array Result */ private function getRooms(Application $app) { $return = array(); $reservationsModel = new ReservationsModel($app); $choice = $reservationsModel->getRooms(); foreach ($choice as $reservation) { $return[$reservation['room_id']] = $reservation['number']; } return $return; }
/** * Delete action. * * @access public * @param Silex\Application $app Silex application * @param Symfony\Component\HttpFoundation\Request $request Request object * @return string Output */ public function deleteAction(Application $app, Request $request) { try { $reservationsModel = new ReservationsModel($app); $id = (int) $request->get('id', null); if (!$reservationsModel->reservSecurity($id)) { return $app->redirect($app['url_generator']->generate('reservations_list'), 301); } $ok = (int) $request->get('ok', null); if ($ok) { $reservationsModel->delete($id); $app['session']->getFlashBag()->add('message', array('type' => 'success', 'content' => $app['translator']->trans('Reservation deleted.'))); return $app->redirect($app['url_generator']->generate('reservations_list'), 301); } $this->view['id'] = $id; } catch (\PDOException $e) { $app->abort(500, $app['translator']->trans('Something went wrong.')); } return $app['twig']->render('reservations/delete.twig', $this->view); }