1.配置模糊查询的路由 Route:: get( ' widget ',function(){ $filter = [[ ' id ', ' > ', ' 0 '],[ ' title ', ' like ', ' %aa% ']]; $data = Widget::datalist( " article ", " widget.list ",$filter, 4); // dd($filter); }); 2.在widgets.php下注册widget <?php Widget::register( ' datalist ', function($model, $view, $filter=[], $limit= 10) { $model = Str::studly($model); $data = $model:: where(function($query) use($filter){ foreach ($filter as $v) { $query-> where($v[ 0], $v[ 1], $v[ 2]); } })->toSql(); // dd($data); });