Closed
Description
For some reason, this method began to return an empty array, although there is data.
Previously, it was the of
method. If you replace it - it does not work either.
Code snippet of problem
$res = new Collection;
foreach ($data as $company) {
$company = (object)$company;
if (gettype($company->properties) === 'array') {
$company->properties = (object)$company->properties;
}
$res->push([
'id' => $company->id,
'company_name' => property_exists($company->properties, 'company_name') ? $company->properties->company_name : '',
'company_phone' => property_exists($company->properties, 'company_phone') ? $company->properties->company_phone : '',
]);
}
// Make sure that there is data in the $res.
// dd($res);
return DataTables::make($res)
->addColumn('action', function ($company) {
return '<a href="' . route('company_edit', $company['id']) . '" class="btn btn-xs btn-primary">Edit</a>';
})->toJson();
System details
- Operating System Ubuntu 17.10
- PHP Version 7.1
- Laravel Version 5.7
- Laravel-Datatables Version 8.13.4