filter(function ($query) { if (request()->has('search')) { $search = request()->get('search'); $query->where('customer_no', 'like', "%" . $search['value'] . "%") ->orWhere('customer_name', 'like', "%" . $search['value'] . "%"); } }) ->addColumn('customer',function($model){ return $model->ACCOUNT_NUMBER; }) ->addColumn('customer',function($model){ return $model->customer; }) ->addIndexColumn() ->addColumn('action', 'customer::_action') ->setRowId('id'); } /** * Get the query source of dataTable. */ public function query(Customer $model): QueryBuilder { return $model->newQuery(); } /** * Optional method if you want to use the html builder. */ public function html(): HtmlBuilder { return $this->builder() ->setTableId('customer-table') ->columns($this->getColumns()) ->minifiedAjax() ->stateSave(false) ->responsive() ->autoWidth(true) ->orderBy(1) ->parameters([ 'scrollX' => true, 'drawCallback' => 'function() { KTMenu.createInstances(); }', ]) ->addTableClass('align-middle table-row-dashed fs-6 gy-5'); } /** * Get the dataTable columns definition. */ public function getColumns(): array { return [ Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false), // Column::make('ID')->title('CIF'), Column::make('CUSTOMER_NO')->title('CUSTOMER NO'), Column::make('NAME_1')->title('NAME'), Column::make('ADDRESS')->title('ADDRESS'), Column::computed('action') ->exportable(false) ->printable(false) ->width(60) ->addClass('text-center'), ]; } /** * Get the filename for export. */ protected function filename(): string { return 'Customer_' . date('YmdHis'); } }