我提到this关于Restful搜索/过滤的通用帖子 . 但是我试图用Yii2设计它 . 我想使用基本的yii2功能搜索ModelSearch并使结果可以作为RESTFul endpoints 访问 . 我的目标有两个让我作为一个用例和我迄今为止所 Build 的内容提出来 .

GET http://app.com/api/v1/cars returns the list of cars
GET api/v1/cars/1 returns the car at id 1
POST api/v1/car creates a new car
PUT api/v1/cars/1 modifies the car at id 1

汽车表有各种列,如名称,制造商,alternate_name . 我希望用户搜索/过滤每个列 . 我可以想象以这种方式实现它

GET api/v1/cars?name=Audi
GET api/v1/cars?technical_name=Quattro

第二种情况是全局搜索,其中用户的任何输入将一次匹配所有列 . 我想过以这种方式实现它:

GET api/v1/cars?search=query
query="Le mans german manufacturer"

所以,我有两个问题 . 这种设计的优缺点是什么?我如何使用默认的Yii2 rest实现(yii \ rest \ ActiveController)来实现它?