Laravel-datatables: Additional variables

Created on 2 Dec 2015  路  9Comments  路  Source: yajra/laravel-datatables

Is there any way to pass along additonal variables with the standards?:

draw:
recordsTotal:
recordsFiltered:
data:

enhancement

Most helpful comment

I think it would be nice if we could have something like:

$users = User::select(['id', 'name', 'email', 'created_at', 'updated_at']);

return Datatables::of($users)
    ->with([
        'key1' => 'value1',
        'key2' => 'value2',
    ])
    ->make(true);   

Tagging as for enhancement.. Will try to implement this. Thanks!

All 9 comments

Good question.. Currently there is no way (there is a workaround) to add variables on the standard response. I guess this is a good enhancement that should be implemented. Thanks!

But if you urgently need this. I think a workaround would be catching the response and then manipulate and add the necessary data. A workaround something like below:

$users = User::select(['id', 'name', 'email', 'created_at', 'updated_at']);

$response = Datatables::of($users)->make(true); 
$data     = $response->getData(true);
$data['key'] = 'value';

return new JsonResponse($data);

I think it would be nice if we could have something like:

$users = User::select(['id', 'name', 'email', 'created_at', 'updated_at']);

return Datatables::of($users)
    ->with([
        'key1' => 'value1',
        'key2' => 'value2',
    ])
    ->make(true);   

Tagging as for enhancement.. Will try to implement this. Thanks!

Great response. Thank you!

Added on upcoming v6.0 release. Thanks!

Is this tagging feature already supported in 6.0? Thanks.

Yes, snippet below is already supported on v6.0.

$users = User::select(['id', 'name', 'email', 'created_at', 'updated_at']);

return Datatables::of($users)
    ->with([
        'key1' => 'value1',
        'key2' => 'value2',
    ])
    ->make(true);   

return Datatables::of($users)
->with([
'key1' => 'value1',
'key2' => 'value2',
])
->make(true);

how i get the value1

How to print in blade ???

Y

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alejandri picture alejandri  路  3Comments

vipin733 picture vipin733  路  3Comments

josiahke picture josiahke  路  3Comments

FilipeBorges1993 picture FilipeBorges1993  路  3Comments

shadoWalker89 picture shadoWalker89  路  3Comments