Example #1
0
 protected function getLDHeader()
 {
     if ($this->has_context) {
         $expand = LDModel::hasInclude("context");
         return ["@context" => $this->getContext($expand), "@id" => $this->getLDId(), "@type" => $this->getType()];
     } else {
         return ["@id" => $this->getLDId(), "@type" => $this->getType()];
     }
 }
 public function createAction()
 {
     $model = new Assertion();
     $input = Input::all();
     $validator = $model->validateInput($input);
     if ($validator->fails()) {
         app()->abort(422, $validator->errors()->first());
     }
     $model->fill(["date" => new Carbon(), "mode" => Input::get("mode"), "test_id" => Input::get("test.@id"), "test_type" => Input::get("test.@type"), "result_type" => Input::get("result.@type"), "result_outcome" => Input::get("result.outcome"), "subject_id" => LDModel::getIdFromLdId(Input::get("subject")), "asserted_by" => LDModel::getIdFromLdId(Input::get("assertedBy.@id")), "evaluation_id" => LDModel::getIdFromLdId(Input::get("evaluation"))]);
     $model->save();
     return $this->response($model);
 }
 public function addAction($id)
 {
     /** @var Evaluation $evaluation */
     $evaluation = Evaluation::find($id);
     if (!$evaluation) {
         app()->abort(422, "Parent evaluation not found");
     }
     $model = new Assertion();
     $input = Input::all();
     $validator = $model->validateInput($input);
     if ($validator->fails()) {
         app()->abort(422, $validator->errors()->first());
     }
     $model->fill(["date" => new Carbon(), "mode" => Input::get("mode"), "test_id" => Input::get("test.@id"), "test_type" => Input::get("test.@type"), "result_type" => Input::get("result.@type"), "result_outcome" => Input::get("result.outcome"), "subject_id" => LDModel::getIdFromLdId(Input::get("subject")), "asserted_by" => LDModel::getIdFromLdId(Input::get("assertedBy.@id"))]);
     $model->evaluation()->associate($evaluation);
     $model->save();
     return $this->response($model);
 }