public function post(\Request $request) { $factory = new Factory(); $view = new \View\JsonView(array('success' => true)); $response = new \Response($view); if (!$request->isVar('command')) { throw new \Exception('Bad command'); } switch ($request->getVar('command')) { case 'reserve': $factory->reserve(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), filter_input(INPUT_POST, 'reserved', FILTER_SANITIZE_NUMBER_INT)); break; case 'sober': $factory->sober(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), filter_input(INPUT_POST, 'sober', FILTER_SANITIZE_NUMBER_INT)); break; } return $response; }
public static function assignStudent($student_id, $spot_id) { $game_id = Game::getCurrentId(); $lot_id = Spot::getLotIdFromId($spot_id); self::removeUnclaimedSpot($spot_id); $lottery = self::getLotteryByStudentId($student_id); if (!$lottery) { $lottery = new Resource(); $lottery->setGameId($game_id); $lottery->setStudentId($student_id); } $lottery->setLotId($lot_id); $lottery->setSpotId($spot_id); $lottery->setPickedUp(true); $lottery->setWinner(true); self::saveResource($lottery); return true; }