Laravel-datatables: use laravel Resource Collections instead of transformers

Created on 1 Oct 2018  路  2Comments  路  Source: yajra/laravel-datatables

Is there's a way to use Laravel resource Collections instead of transformers

    $data = Sport::select(['id', 'title', 'icon', 'status_id', 'updated_at'])
        ->with('status:id,status')
        ->withCount('users');

    return DataTables::make($data)
        ->setTransformer(new SportTransformer())
        ->toJson();
question

Most helpful comment

The feature is released in yajra/laravel-datatables-fractal v1.3.0
thnx @yajra

All 2 comments

if @yajra accepts my PR you'll be able to do at least:

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

The feature is released in yajra/laravel-datatables-fractal v1.3.0
thnx @yajra

Was this page helpful?
0 / 5 - 0 ratings