public function scopeSearchByKeyword($query, $keyword)
{
if ($keyword!='') {
$query->where(function ($query) use ($keyword) {
$query->where("name", "LIKE","%$keyword%")
->orWhere("email", "LIKE", "%$keyword%")
->orWhere("blood_group", "LIKE", "%$keyword%")
->orWhere("phone", "LIKE", "%$keyword%");
});
}
return $query;
}
'$ query'参数用于什么?函数($ query)使用($ keyword){}是什么意思?
$keyword = Input::get('keyword', '');
$users = User::SearchByKeyword($keyword)->get();
为什么它只是'SearchByKeyword'而不是scopeSearchByKeyword?