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');
}
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');
}
转载于:https://my.oschina.net/u/2444569/blog/531082