我想通过URL将要从数据库返回的字段传递给Transfomer中的我知道要返回的字段。我可以将第三个参数传递给转换器吗?
url
192.168.99.100:88/v1/declarations/type?filter[]=filter1&filter[]=filter2&filter[]=filter3
索引
public function index(Request $request)
{
$fields = $request->get('filter');
$filters = [];
if ($request->has('type')){
$filters['type'] = $request->get('type', null);
}
if ($request->has('trash')){
$filters['trash'] = $request->get('trash', 0);
}
if ($request->has('status')){
$filters['status'] = $request->get('status', null);
}
$results = $this->declarationTypeRepository->allDeclarationType($filters);
return $this->successResponse($this->transform( $results, DeclarationTypeTransformer::class), 200);
}