eloquent($query)
->addColumn('amount', function ($data) {
return format_currency($data->amount);
})
->addColumn('action', function ($data) {
return view('sale::payments.partials.actions', compact('data'));
});
}
public function query(SalePayment $model) {
return $model->newQuery()->bySale()->with('sale');
}
public function html() {
return $this->builder()
->setTableId('sale-payments-table')
->columns($this->getColumns())
->minifiedAjax()
->dom("<'row'<'col-md-3'l><'col-md-5 mb-2'B><'col-md-4'f>> .
'tr' .
<'row'<'col-md-5'i><'col-md-7 mt-2'p>>")
->orderBy(5)
->buttons(
Button::make('excel')
->text(' Excel'),
Button::make('print')
->text(' Print'),
Button::make('reset')
->text(' Reset'),
Button::make('reload')
->text(' Reload')
);
}
protected function getColumns() {
return [
Column::make('date')
->className('align-middle text-center'),
Column::make('reference')
->className('align-middle text-center'),
Column::computed('amount')
->className('align-middle text-center'),
Column::make('payment_method')
->className('align-middle text-center'),
Column::computed('action')
->exportable(false)
->printable(false)
->className('align-middle text-center'),
Column::make('created_at')
->visible(false),
];
}
protected function filename(): string {
return 'SalePayments_' . date('YmdHis');
}
}