$result = BookCode::where('book_name','s121212ss')->get(); if ($result) { return [ 'd' => $result, 'c' => 200000, 'm' => '获取成功', ];} else { return [ 'c' => 400000, 'm' => '', 'd' => $result, ];}
因为返回的是一个 Collection,是一个非空对象
if ($result->isNotEmpty()) { // ok } else { // false }
2.1m questions
2.1m answers
60 comments
57.0k users