yajra / laravel-datatables

jQuery DataTables API for Laravel
https://yajrabox.com/docs/laravel-datatables
MIT License
4.76k stars 857 forks source link

Fix Resource example in code or documentation #3191

Open funder7 opened 1 week ago

funder7 commented 1 week ago

Summary of problem or feature request

The problem reported in #2995 has not been fixed. OP said that Yajra Datatables 9.x works with the example provided in the documentation, but users using the latest version are not able to use resources without the workaround provided in the github issue.

It would be nice to do one of the following:

Code snippet of problem

Working

$data     = User::paginate(10);
$resource = User::collection($data);

return Datatables::of($resource->toArray($request))->make();

Documentation example (not working)

$data     = User::paginate(10);
$resource = User::collection($data);

return Datatables::of($resource)->toJson();

System details

yajra commented 1 day ago

Thank you for reporting, will review it as soon as I can. Please do not hesitate to submit a PR if possible.