50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Datatables\Shop;
|
|
|
|
use Yajra\DataTables\Html\Column;
|
|
use App\Datatables\ParentDataTable as DataTable;
|
|
use App\Models\Shop\Tariff;
|
|
use App\Repositories\Shop\Tariffs;
|
|
|
|
class TariffsDataTable extends DataTable
|
|
{
|
|
public $model_name = 'tariffs';
|
|
|
|
public function query(Tariff $model)
|
|
{
|
|
$model = $model->with(['sale_channels'])->select(['shop_tariffs.*']);
|
|
return $this->buildQuery($model);
|
|
}
|
|
|
|
public function modifier($datatables)
|
|
{
|
|
$datatables
|
|
->editColumn('status', function (Tariff $tariff) {
|
|
return Tariffs::getStatus($tariff['status_id']);
|
|
})
|
|
->editColumn('sale_channels2', function (Tariff $tariff) {
|
|
$html = '';
|
|
foreach ($tariff->sale_channels as $sale_channel) {
|
|
$html .= $sale_channel->code . ', ';
|
|
}
|
|
return $html;
|
|
})
|
|
->rawColumns(['sale_channels2', 'action'])
|
|
;
|
|
return parent::modifier($datatables);
|
|
}
|
|
|
|
protected function getColumns()
|
|
{
|
|
return [
|
|
Column::make('status_id')->data('status')->title('status'),
|
|
Column::make('name')->title('Nom'),
|
|
Column::make('sale_channels2')->title('Canaux de vente'),
|
|
Column::make('code')->title('Code'),
|
|
Column::make('ref')->title('Référence'),
|
|
$this->makeColumnButtons(),
|
|
];
|
|
}
|
|
}
|