Skip to content

Conversation

@c00p3r
Copy link
Contributor

@c00p3r c00p3r commented Nov 14, 2018

Original Fractal package allows closures as transformers (https://fractal.thephpleague.com/transformers/)
so it would be good and useful to leave that feature
SO it for example will allow folks to transform the data using Laravel API Resource like this

return DataTables::eloquent($query)
            ->setTransformer(function ($item){
                return Resource::make($item)->resolve();
            })
            ->make();

Also, if you accept this PR, would be probably nice to update 'datatables' docs chapter 'Response > Fractal Transformer'

Original Fractal package allows closures as transformers (https://fractal.thephpleague.com/transformers/)
so it would be good and useful to leave that feature
SO it for example will allow folks to transform the data using Laravel API Resource like this
```
return DataTables::eloquent($query)
            ->setTransformer(function ($item){
                return Resource::make($item)->resolve();
            })
            ->make();
```
@c00p3r
Copy link
Contributor Author

c00p3r commented Nov 14, 2018

I'm not the only one yajra/laravel-datatables#1863

@yajra
Copy link
Owner

yajra commented Nov 15, 2018

Wow, love this PR. It makes the resource integration easier. Thanks a lot! ❤️ 🍻

@yajra yajra merged commit 3035f68 into yajra:1.0 Nov 15, 2018
@yajra
Copy link
Owner

yajra commented Nov 15, 2018

Released on v1.3.0. For the docs, it's located on https://github.com/yajra/laravel-datatables-docs/blob/master/response-fractal.md. Would you mind sending a PR too? Thanks!

@c00p3r
Copy link
Contributor Author

c00p3r commented Nov 15, 2018

Wow! That was fast! Thank you too!
I'll update the datatables docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants