This happens with Laravel 4.2 and yajra / laravel-datatables-oracle ":" ~ 3.0 "
The table is rendered and is already paging, however, the order and filter does not work. In fact it always returns the same information, as if the filter were not applied. Is there anything else necessary to make everything work by considering the existing joins?
My Controller:
public function api() {
$params = Input::all();
$warehouse = $this->warehouse->getDefaultByTenant(current_tenant());
$items = $this->inventory->dataTables($warehouse, $params);
return $items;
}
My Repository:
public function dataTables(Warehouse $warehouse, $params) {
$a = DB::table('inventories')
->join('variants', 'inventories.variant_id', '=', 'variants.id')
->join('tenant_variants', 'inventories.variant_id', '=', 'tenant_variants.id')
->join('products', 'variants.product_id', '=', 'products.id')
->join('variant_translations', 'variant_translations.variant_id', '=', 'variants.id', 'left outer')
->join('product_translations', 'product_translations.product_id', '=', 'products.id')
->where('inventories.warehouse_id', $warehouse->id)
->where('product_translations.locale', $warehouse->getTenantLocale())
->whereNull('variants.deleted_at')->orderBy('product_translations.name');
if (isset($params['search[value]']) && ($k = $params['search[value]'])) {
$query = $query
->where(function ($subquery) use ($k) {
return $subquery
->where('product_translations.name', 'like', "%%{$k}%%")
->orWhere('variants.sku', 'like', "%%{$k}%%")
->orWhere('variant_translations.name', 'like', "%%{$k}%%");
});
}
return Datatables::of($a)->addColumn('actions', 'action here')->make(true);
}
My JS
$('.table-inventory').DataTable( {
"processing": true,
"serverSide": true,
"ajax": {url: "route_to_api", dataSrc: "data"},
columns: [
{ data: 'sku' },
{ data: 'name' },
{ data: 'position' },
{ data: 'count_on_hand' },
{ data: 'count_on_hand' },
{ data: 'critical_stock_level' },
{ data: 'retail_price' },
{ data: 'wholesale_price' },
{ data: 'qty1_threshold' },
{ data: 'qty2_threshold' },
{ data: 'permalink_classico' },
{ data: 'ml_classico_price' },
{ data: 'id_ml_premium' },
{ data: 'ml_premium_price' },
]
} );
I was able to solve the filters, I did it manually, but now I need to resolve the ordering.