laravel with查询的时候 怎么写多个查询条件
两个表
book表
id name name_en user_id type_id
content
id name name_en user_id type_id
在book表 with查询content
BOOK表 模型
public function contents()
{
return $this->hasMany(Content::class, 'user_id', 'user_id');
}
->with('contents', function ($query) {
$query->whereColumn('book.type_id', '=', 'content.type_id')->select('*');
});
上面这样写不对
推荐文章: