我正在使用关系显示具有模型的数据集合。...
public function index($id){
$user = User::with('files.comment',
'files.likes','files.dislike')->get()->find($id);
// return response()->json(['data' => $user], 200,[],JSON_NUMERIC_CHECK);
//while using return response i am getting all my data bt using whrn trait showall method it gives arguments pass error
return $this->showall($user);
}
我的性状特征响应
protected function showall(Collection $collection, $code = 200){
if ($collection ->isEmpty()) {
return $this->successResponse(['data'->$collection],$code);
}
$transformer = $collection->first()->transformer;
$collection = $this->sortData($collection, $transformer);
$collection = $this->transformData($collection, $transformer);
return $this->successResponse( $collection,$code);
}
如何解决此问题,请告诉我...