如何在dingo api 的transform里传其它参数?

我需要在transformer里接受一个其他参数,怎么传值?

$this->response()->item($recommend, new SingleClassTransformer());

JellyBool
$this->response()->item($recommend, new SingleClassTransformer($param));

这样么?

bii 回复 JellyBool

这样的话,会报错诶。我该在哪里接收呢

JellyBool 回复 bii

那我就不清楚你的需求了

bii 回复 JellyBool

就是说在这里传
···
this>response()>item(this->response()->item(recommend, new SingleClassTransformer(param)); ··· 我在SingleClassTransformer里面该怎么获取到param呢

JellyBool 回复 bii

不就是从构造函数获取么。。。。

bii 回复 JellyBool

好吧,煞笔了。。。以为只能写个transform方法