多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
>[danger] 使用示例 + 定义搜索器 ``` // title 字段搜索器 模糊查询 public function searchTitleAttr($query, $value, $data) { $query->where('title', 'like', '%' . $value . '%'); } // create_time 字段搜索器 时间范围查询 public function searchCreateTimeAttr($query, $value, $data) { $query->whereBetweenTime('create_time', $value[0], $value[1]); } ``` + 在模型中执行使用搜索器的查询 ``` // 字段限定 title create_time $field = ['title', 'create_time']; // 传入的数据 $data = [ 'name' => 'think', 'create_time' => ['2018-8-1','2018-8-5'], ]; // 执行使用搜索器的查询 $res = self::withSearch($field, $data)->select(); // 实际执行的SQL语句 // SELECT * FROM `admin` WHERE `title` LIKE '%think%' AND `create_time` BETWEEN '2018-8-1' AND '2018-8-5' ```