hasMany关系还没有withTrashed()

时间:2019-06-04 15:05:27

标签: laravel laravel-5

我在StackOverflow上看到了类似问题的答案:https://stackoverflow.com/a/40654005/1055279

我在这里看到

public function order() {
     return $this->belongsToMany('Order')->withTrashed();
 }

在我的情况下,我有Customer个具有 n Device s

的模型
// Relation 1 to n from Customer model to Device model
public function devices()
{
    return $this->hasMany('App\Device')->withTrashed();
}

请注意,我已经添加了Trashed,因为我总是需要检索softDeleted数据。

问题

从我得到的客户模型中获取设备

  

消息:“调用未定义的方法     照亮\数据库\口才\关系\ HasMany :: withTrashed()“

可能我使用了错误的语法。我在这里想请您帮助。

  • Laravel是@ 5.8.19
  • PHP是@ 7.2.x

1 个答案:

答案 0 :(得分:0)

认为目标模型不是使用SoftDelete特征。

固定。

相关问题