51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Datatables\Shop;
|
|
|
|
use App\Datatables\ParentDataTable as DataTable;
|
|
use App\Models\Shop\Delivery;
|
|
use Yajra\DataTables\Html\Column;
|
|
|
|
class DeliveriesDataTable extends DataTable
|
|
{
|
|
public $model_name = 'deliveries';
|
|
|
|
public function query(Delivery $model)
|
|
{
|
|
$model = $model->with('sale_channel');
|
|
|
|
return $this->buildQuery($model);
|
|
}
|
|
|
|
public function modifier($datatables)
|
|
{
|
|
$datatables
|
|
->editColumn('active', function (Delivery $delivery) {
|
|
return view('components.form.toggle', [
|
|
'value' => $delivery->active,
|
|
'on' => __('active'),
|
|
'off' => __('inactive'),
|
|
'meta' => 'data-id='.$delivery->id,
|
|
'size' => 'sm',
|
|
]);
|
|
})
|
|
->editColumn('address', function (Delivery $delivery) {
|
|
return $delivery->address.' '.$delivery->zipcode.' '.$delivery->city;
|
|
})
|
|
->rawColumns(['active', 'address', 'action']);
|
|
|
|
return parent::modifier($datatables);
|
|
}
|
|
|
|
protected function getColumns()
|
|
{
|
|
return [
|
|
Column::make('active')->title(__('active'))->width(60)->class('text-center'),
|
|
Column::make('name')->title('Nom'),
|
|
Column::make('sale_channel.name')->title(__('shop.sale_channels.name')),
|
|
Column::make('address')->title('Adresse')->searchable(false),
|
|
$this->makeColumnButtons(),
|
|
];
|
|
}
|
|
}
|