【发布时间】:2023-03-14 22:06:02
【问题描述】:
我想按type_order 对查询进行排序:
public function posts()
{
if (($this->type_order) == '1') {
$type = 'id';
return $this->belongsToMany(Post::class, 'feed_posts')->orderBy($type);
}
}
但得到错误:
FatalThrowableError
Call to a member function addEagerConstraints() on null
【问题讨论】:
-
你在哪里声明 posts() 方法?