add module konfirmasibank
This commit is contained in:
100
DataTables/CustomerDataTable.php
Normal file
100
DataTables/CustomerDataTable.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
//namespace App\DataTables;
|
||||
namespace Modules\Konfirmasibank\DataTables;
|
||||
|
||||
use Modules\Konfirmasibank\Entities\Customer;
|
||||
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
|
||||
use Yajra\DataTables\EloquentDataTable;
|
||||
use Yajra\DataTables\Html\Builder as HtmlBuilder;
|
||||
use Yajra\DataTables\Html\Button;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use Yajra\DataTables\Html\Editor\Editor;
|
||||
use Yajra\DataTables\Html\Editor\Fields;
|
||||
use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class CustomerDataTable extends DataTable
|
||||
{
|
||||
/**
|
||||
* Build the DataTable class.
|
||||
*
|
||||
* @param QueryBuilder $query Results from query() method.
|
||||
*/
|
||||
public function dataTable(QueryBuilder $query): EloquentDataTable
|
||||
{
|
||||
|
||||
return (new EloquentDataTable($query))
|
||||
->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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user