// AuthenticateTransformers
public function transform(Customer $customer)
{
return [
'id' => $customer['id'],
'name' => $customer['name'],
'username' => $customer['username'],
'secret' => $customer['secret'],
'startDate' => $customer['startDate'],
'endDate' => $customer['endDate'],
'token' => $customer['token'],
];
}
/**
* @param \App\Models\Customer $customer
*
* @return array
*/
public function getAuthenticatedUser(Customer $customer)
{
return [
'id' => $customer['id'],
'name' => $customer['name'],
'username' => $customer['username'],
'secret' => $customer['secret'],
'startDate' => $customer['startDate'],
'endDate' => $customer['endDate'],
];
}
// 回调
return $this->item($customer, new AuthenticateTransformers, function ($resource, $fractal) {
$fractal->setSerializer(new CustomSerializer());
});
查阅了一些文档,new Transformers的时候默认transform方法,
但是不能一个文件就为这一个方法而存吧,
我怎么在回调的时候想指向自定义的方法比如getAuthenticatedUser这个方法