model = $model; } public function updateName(int $tactic_id): HttpResponse { return Control::runChecked([ "name" => [Validators::lenBetween(1, 50), Validators::nameWithSpaces()] ], function (HttpRequest $request) use ($tactic_id) { $this->model->updateName($tactic_id, $request["name"]); return HttpResponse::fromCode(HttpCodes::OK); }); } public function newTactic(): HttpResponse { return Control::runChecked([ "name" => [Validators::lenBetween(1, 50), Validators::nameWithSpaces()] ], function (HttpRequest $request) { $tactic = $this->model->makeNew($request["name"]); $id = $tactic->getId(); return new JsonHttpResponse(["id" => $id]); }); } public function getTacticInfo(int $id): HttpResponse { $tactic_info = $this->model->get($id); if ($tactic_info == null) { return new JsonHttpResponse("could not find tactic #$id", HttpCodes::NOT_FOUND); } return new JsonHttpResponse($tactic_info); } }