41 lines
1012 B
PHP
41 lines
1012 B
PHP
<?php
|
|
|
|
namespace App\Datatables\Shop;
|
|
|
|
use Yajra\DataTables\Html\Column;
|
|
use App\Datatables\ParentDataTable as DataTable;
|
|
use App\Models\Shop\PriceList;
|
|
|
|
class PriceListsDataTable extends DataTable
|
|
{
|
|
public $model_name = 'price_lists';
|
|
|
|
public function __construct()
|
|
{
|
|
$this->url = route('Admin.Shop.PriceLists.index');
|
|
}
|
|
|
|
public function query(PriceList $model)
|
|
{
|
|
$model = $model->with('sale_channel');
|
|
$model = self::filterByTariff($model);
|
|
return self::buildQuery($model);
|
|
}
|
|
|
|
public static function filterByTariff($model, $tariff_id = false)
|
|
{
|
|
$tariff_id = $tariff_id ? $tariff_id : self::isFilteredByField('tariff_id');
|
|
return $tariff_id ? $model->byTariff($tariff_id) : $model;
|
|
}
|
|
|
|
|
|
protected function getColumns()
|
|
{
|
|
return [
|
|
Column::make('name')->title('Nom'),
|
|
Column::make('sale_channel.name')->title('Canal de vente'),
|
|
self::makeColumnButtons(),
|
|
];
|
|
}
|
|
}
|