Php Laravel查询删除关系

Php Laravel查询删除关系,php,laravel,laravel-5.1,Php,Laravel,Laravel 5.1,我的模型是Patient->Sample,我删除了一个患者,我通过withTrashed()查询删除的患者,但不通过withTrashed()查询删除的患者的样本 病人室控制器 class Patient_Controller extends Controller{ public function query(Request $request){ $result = Patient_Model::withTrashed(); ->orderBy("updated

我的模型是
Patient->Sample
,我删除了一个患者,我通过
withTrashed()查询删除的患者,但不通过
withTrashed()查询删除的患者的样本

病人室控制器

class Patient_Controller extends Controller{

public function query(Request $request){

    $result = Patient_Model::withTrashed();
        ->orderBy("updated_at","desc")
        ->Paginate(15)
        ->toJson();

   return $result;
}
class Sample_Controller extends Controller{

public function query(Request $request){

    $result = Sample_Model::with('patient')
        ->withTrashed()
        ->orderBy("updated_at","desc")
        ->Paginate(15)
        ->toJson();

   return $result;
}
但在样本控制器中

class Patient_Controller extends Controller{

public function query(Request $request){

    $result = Patient_Model::withTrashed();
        ->orderBy("updated_at","desc")
        ->Paginate(15)
        ->toJson();

   return $result;
}
class Sample_Controller extends Controller{

public function query(Request $request){

    $result = Sample_Model::with('patient')
        ->withTrashed()
        ->orderBy("updated_at","desc")
        ->Paginate(15)
        ->toJson();

   return $result;
}

但由于没有找到删除患者,因此我的样本无法获取患者信息

如果我正确理解了您的问题,您试图将垃圾患者包括在您的with中?如果是,请尝试以下方法

public function query(Request $request){

  $result = Sample_Model::with(['patient' => function($q) {
        $q->withTrashed();
    }])
    ->withTrashed()
    ->orderBy("updated_at","desc")
    ->Paginate(15)
    ->toJson();

  return $result;
}

(['relationship\u alley'])的
是什么?请出示您的
患者模型
样本模型
好吗?另外,我也不太清楚你想达到什么目的。使用(['relationship\u-alley']),relationship\u-alley是示例模型,功能是正确的,我成功了,对不起,我的英语太差了,谢谢。你能帮我回答其他问题吗?谢谢