阅读(95) (0)

Laravel 8 判断记录是否存在

2021-07-07 09:14:19 更新

除了通过 count 方法可以确定查询条件的结果是否存在之外,还可以使用 existsdoesntExist 方法:

return DB::table('orders')->where('finalized', 1)->exists();

return DB::table('orders')->where('finalized', 1)->doesntExist();