I'm having issues with pagination after I use a resource to display data. Before this, I was using this code to display data, and the output shows the pagination as well.
Controller
$All = Customers::with('order')->paginate(10);
return response()->json([
'code' => 0,
'success' => true,
'data' => $All,
], 200);
But right after I'm using Resources to display data, the pagination is gone.
$All = Customers::with('order')->paginate(10);
return response()->json([
'code' => 0,
'success' => true,
'data' => DataResource::collection($All),
], 200);
DataResource
public function toArray($request)
{
//return parent::toArray($request);
return [
'name' => $this->name,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'order' => Resources::collection($this->order)
];
}