时间:2021-07-01 10:21:17 帮助过:2人阅读
1.
find --> 返回 object or empty
ex:
$p = Project::find($id);if(empty($p)) { dd(‘project is empty‘); }
get --> 返回object , 透过count 方法判断
ex:
$p = Project::where(‘user_id‘, ‘=‘, $userid)->get();if($p->count() == 0) { dd(‘project is empty‘); }
判断 laravel的model 的数据库为空
标签: