/**
  * Tests the update function in the SpecimenRejectionController
  */
 public function testDelete()
 {
     Input::replace($this->rejectionReasonData);
     $rejectionReason = new SpecimenRejectionController();
     $rejectionReason->store();
     $rejectionReasonstored = RejectionReason::orderBy('id', 'desc')->take(1)->get()->toArray();
     $rejectionReason->delete($rejectionReasonstored[0]['id']);
     $rejectionReasonDeleted = RejectionReason::find($rejectionReasonstored[0]['id']);
     $this->assertNull($rejectionReasonDeleted);
 }
 /**
  * Remove the specified resource from storage (soft delete).
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     //Soft delete the rejection
     $rejection = RejectionReason::find($id);
     $inUseBySpecimen = $rejection->specimen->toArray();
     try {
         // The rejection is not in use
         $rejection->delete();
     } catch (Exception $e) {
         // The rejection is in use
         $url = Session::get('SOURCE_URL');
         return Redirect::to($url)->with('message', trans('messages.failure-specimen-rejection-reason-in-use'));
     }
     // redirect
     $url = Session::get('SOURCE_URL');
     return Redirect::to($url)->with('message', trans('messages.success-deleting-rejection-reason'));
 }