Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel Larvel:允许在hasManyThrough关系中软删除模型_Laravel_Laravel 5_Laravel 5.1 - Fatal编程技术网

Laravel Larvel:允许在hasManyThrough关系中软删除模型

Laravel Larvel:允许在hasManyThrough关系中软删除模型,laravel,laravel-5,laravel-5.1,Laravel,Laravel 5,Laravel 5.1,我有很多这样的关系: class Venue { public function orders() { return $this->hasManyThrough(Order::class, Offer::class); } } 但是,优惠型号可以软删除: 这意味着该功能将不会返回包含软删除报价的任何订单 如何允许该功能返回包含软删除报价的订单 请注意,我使用的是Laravel 5.1(尽管欢迎使用更新版本的解决方案)。 您可以在关系上使用->wit

我有很多这样的关系:

class Venue {
    public function orders()
    {
        return $this->hasManyThrough(Order::class, Offer::class);
    }
}
但是,
优惠
型号可以软删除:

这意味着该功能将不会返回包含软删除报价的任何订单

如何允许该功能返回包含软删除报价的订单

请注意,我使用的是Laravel 5.1(尽管欢迎使用更新版本的解决方案)。


您可以在关系上使用
->withTrashed()
方法。

但这是否包括trashed for offers或Orders我现在没有可用的Laravel,但我认为您可以通过在hasManyThrough()方法后面添加->withTrashed()方法来实现。如果这不起作用,我建议您在Order类中要提供的关系后面添加withTrashed()方法。其中一个可以解决您的问题。
$this->withTrashed()->hasManyThrough(Order::class,Offer::class)
调用未定义的方法lightize\Database\Query\Builder::hasManyThrough()错误您应该扭转它,就像这样:
$this->hasManyThrough(Order::class,Offer::class)->withTrashed()一样
这给了我:
调用undefined方法illumb\Database\Query\Builder::withTrashed()