I want to use pagination after getting my data from api resource But the server responds:
Method Illuminate\Database\Eloquent\Collection::pagination does not exist.
public function index(Request $request )
{
$perPage=$request->per_page;
return response()->json(['user'=>UserResource::collection(User::with('roles')->get()->pagination($perPage))],200);
}