[WIP] Working on orders & invoices
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
namespace App\Datatables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Order;
|
||||
use App\Repositories\Shop\InvoicePayments;
|
||||
use App\Repositories\Shop\Orders;
|
||||
|
||||
class OrdersDataTable extends DataTable
|
||||
{
|
||||
@@ -12,13 +15,38 @@ class OrdersDataTable extends DataTable
|
||||
|
||||
public function query(Order $model)
|
||||
{
|
||||
$model = $model->with(['customer', 'delivery']);
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('status', function (Order $order) {
|
||||
return Orders::getStatus($order->status);
|
||||
})
|
||||
->editColumn('created_at', function (Order $order) {
|
||||
return $order->created_at->toDateTimeString();
|
||||
})
|
||||
->editColumn('customer.last_name', function (Order $order) {
|
||||
return $order->customer->last_name . ' ' . $order->customer->first_name;
|
||||
})
|
||||
->editColumn('payment_type', function (Order $order) {
|
||||
return InvoicePayments::getPaymentType($order->payment_type);
|
||||
})
|
||||
->rawColumns(['action']);
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('status')->title('Statut'),
|
||||
Column::make('created_at')->title('Date'),
|
||||
Column::make('customer.last_name')->title('Client'),
|
||||
Column::make('delivery.name')->title('Point de distribution'),
|
||||
Column::make('payment_type')->title('Règlement'),
|
||||
Column::make('total_shipped')->title('Montant')->class('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user