I have the following code snippet using laravel and the Datatables package
$products = Product::with('enterprise')
->select(['id', 'enterprise_id', 'name'])
->whereIn('enterprise_id', [1, 2]);
return Datatables::of($products)
->editColumn('enterprise_id', function($product){
return $product->enterprise->name;
})
->make();
And I have the following json as a return:
[
"12",
"Nome empresa",
"Nome do produto",
{
"id": 1,
"client_id": 1,
"name": "Nome empresa",
"created_at": "2016-08-25 16:38:24",
"updated_at": "2016-08-25 16:38:24"
}
]
How to remove that json snippet where the relationship appears? What I would like to take away is this part of json:
{
"id": 1,
"client_id": 1,
"name": "Nome empresa",
"created_at": "2016-08-25 16:38:24",
"updated_at": "2016-08-25 16:38:24"
}
I have already tried using the removeColumn
feature without success. And I've also tried to add a new column nome_empresa
and removing the column enterprise_id
but also without success.
The result I expected to receive in json would be:
[
"12",
"Nome empresa",
"Nome do produto",
]