我在我的应用程序上有一个名为Shift的模型,我在它上面定义了我的关系和作用域,如下所示: 关系: public function status() return $this->belongsTo"message": "Method Illuminate\\Database\\Eloquent\\Collection::withStatus does not exist.
由于我一直在关注Eloquent Performance Patterns by Jonathan Reinink,他解释了如何使用子查询为具有多个关系的模型添加动态关系。但根据我的申请,我需要为任何关系做同样的事情。请帮我实现它。 下面是示例源代码,它使用子查询具有多个关系的模型来实现上述动态关系。