Краткое описание проблемы
Поле поиска по умолчанию для глобальной фильтрации в таблицах данных yajra, фильтрует только один первый столбец , но не другие. При попытке возвращает " Совпадений не найдено ". Фильтрация по настраиваемому столбцу Добавлено или Отредактировано больше не работает .. Я не могу найти проблемы.
Фрагмент кодапроблема в функции контроллера:
$invoices = Invoice::where('branchid', 1)->where('status', 1)->with('branch', 'customer')->withCount(['Sales', 'ImmediateSales']);
return Datatables::of($invoices)
->editColumn('branchid', function ($invoice) {
return $invoice->branch->branchname;
})
->editColumn('customer_id', function ($invoice) {
return $invoice->customer->name;
})
->addColumn('total', function ($invoice) {
$total = $invoice->totalamount + $invoice->vatamount - $invoice->offeramount - $invoice->discount - $invoice->rebate;
return $total;
})
->addColumn('due', function ($invoice) {
$due = $invoice->due;
if ($due > 0) {
if ($invoice->due_omitted) {
$due = "<del>$due</del>";
}
$due ="<span class='label-danger' title='Due Omitted'> $due </span>";
}
return $due;
})
->addColumn('type', function ($invoice) {
$type = null;
if (($invoice->sales_count) && ($invoice->immediate_sales_count)) {
$type = "Both";
}else if (($invoice->sales_count) && !($invoice->immediate_sales_count)) {
$type = "Normal";
} else if (!($invoice->sales_count) && ($invoice->immediate_sales_count)) {
$type = "Immediate";
}
return $type;
})
->addColumn('created_at', function ($invoice) {
return "<span data-title='".Carbon::parse($invoice->created_at)->format('h:m A')."'>".Carbon::parse($invoice->created_at)->format('d M Y')."</span>";
})
->addColumn('action', function ($invoice) {
$btn = '<div class="table-actions text-right">';
if(Auth::user()->can("invoice-view")){
$btn .= '<button type="button" class="btn btn-primary btn-xs view-btn" data-toggle="modal" data-target="#product-details" value="'.$invoice->invoiceid.'"><i class="fa fa-eye" aria-hidden="true"></i> View</button>';
}
if(Auth::user()->can("invoice-print")) {
$btn .= ' <a href="/print-invoice/' . $invoice->invoiceid . '" class="btn btn-warning btn-xs" aria-hidden="true" target="_blank"><i class="fa fa-print" aria-hidden="true"></i>Print</a> ';
}
if (!$invoice->historyId && $invoice->qty && Auth::user()->can('sale-return')) {
$btn .= ' <a type="button" href="/return-invoice/'.$invoice->invoiceid.'" class="btn btn-info btn-xs" data-dismiss="modal" aria-hidden="true"><i class="fa fa-reply" aria-hidden="true"></i> Return</a> ';
}
if(Auth::user()->can("invoice-delete")) {
$btn .= ' <button class="btn btn-danger btn-xs delete-btn" data-dismiss="modal" aria-hidden="true" value="'.$invoice->invoiceid.'"><i class="fa fa-eye-slash" aria-hidden="true"></i> Delete </button> ';
}
$btn .= '</div>';
return $btn;
})
->rawColumns(['due','created_at', 'action'])
->make(true);
в блейд-файле:
<table id="allInvoiceTBL" class="table table-hover table-responsive ">
<thead>
<th>Id</th>
<th>Branch</th>
<th>Customer</th>
<th>Total</th>
<th>Due</th>
<th>Type</th>
<th>Date</th>
<th class="text-center"> Action</th>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
$('#allInvoiceTBL').DataTable({
processing: true,
serverSide: true,
ajax: "{{ route('invoice-all') }}",
deferRender: true,
order: [[0, "desc"]],
columns: [
{data: 'invoiceid', name: 'invoiceid'},
{data: 'branchid', name: 'branchid'},
{data: 'customer_id', name: 'customer_id'},
{data: 'total', name: 'total'},
{data: 'due', name: 'due'},
{data: 'type', name: 'type'},
{data: 'created_at', name: 'created_at'},
{data: 'action', name: 'action', orderable: false, searchable: false},
]
});
Конфигурация моей системы:
- Версия PHP: 7.2.12
- Версия Laravel: 5.7.28
- Версия Laravel-Datatables: 8.13.7