当接收到参数是执行搜索
public function index($name=null){ if (isset($_REQUEST['username'])) { $name = $_REQUEST['username']; $res = (new Model)->like($name); }else{ $res = (new Model)->lst(); } $this->assign([ 'name'=>$name, "res"=>$res ]); return view("index"); }
模块
public function like($name){ return db('xxx') ->where('name','like','%'.$name.'%') ->paginate(1,false,['query'=>request()->param()]); }