用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
>[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' ```