ORM查询条件为关联模型返回数量的条件如何写?
users 表对应 User 模型,notes 表对应 Note 模型;如果我要查找一个 note 也没有的用户,用 ORM 怎么写?
<?php
namespace App\Models;
class User{
......
......
public function note()
{
return $this->hasMany(Note::class);
}
}
namespace App\Http\Controllers;
use App\Models\User;
class UserController{
public function noNoteList(){
$where = [];//查找一个note也没有的用户 查询条件要怎么写?
return User::where($where)->paginate(10);
}
}
推荐文章: