/** * Tests the update function in the OrganismController * @param void * @return void */ public function testUpdate() { $this->withoutMiddleware(); $this->call('POST', '/organism', $this->organismData); $organismStored = Organism::orderBy('id', 'desc')->first(); $this->withoutMiddleware(); $this->call('PUT', '/organism/' . $organismStored->id, $this->organismDataUpdate); $organismSavedUpdated = Organism::find($organismStored->id); $this->assertEquals($organismSavedUpdated->name, $this->organismDataUpdate['name']); $this->assertEquals($organismSavedUpdated->description, $this->organismDataUpdate['description']); //Getting the drugs related to the organism /*$organismDrugUpdated = Organism::find($organismStored->id)->drugs->toArray(); $this->assertEquals(12, $this->organismDataUpdate['drugs'][0]);*/ }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { //Get the testtype $testtype = TestType::find($id); $measures = Measure::all(); $measuretype = MeasureType::all()->sortBy('id'); $specimentypes = SpecimenType::orderBy('name')->get(); $testcategory = $testtype->testCategory->id; $testcategories = TestCategory::lists('name', 'id'); $organisms = Organism::orderBy('name')->get(); //Open the Edit View and pass to it the $testtype return view('testtype.edit', compact('testtype', 'testcategories', 'testcategory', 'measures', 'measuretype', 'specimentypes', 'organisms')); }
/** * @return \Illuminate\Routing\Route|null|string */ public function ingnoreId() { $id = $this->route('organism'); $name = $this->input('name'); return Organism::where(compact('id', 'name'))->exists() ? $id : ''; }
/** * Remove the specified resource from storage (soft delete). * * @param int $id * @return Response */ public function delete($id) { //Soft delete the organism $organism = Organism::find($id); /*$testCategoryInUse = TestType::where('test_category_id', '=', $id)->first(); if (empty($testCategoryInUse)) { // The test category is not in use $testcategory->delete(); } else { // The test category is in use $url = session('SOURCE_URL'); return Redirect::to($url) ->with('message', trans('terms.failure-test-category-in-use')); }*/ // redirect $url = session('SOURCE_URL'); return redirect()->to($url)->with('message', trans('terms.record-successfully-deleted')); }