<?php

namespace App\Datatables\Shop;

use Yajra\DataTables\Html\Column;
use App\Datatables\ParentDataTable as DataTable;
use App\Models\Shop\SaleChannel;

class SaleChannelsDataTable extends DataTable
{
    public $model_name = 'sale_channels';

    public function query(SaleChannel $model)
    {
        $model = $model->withCount(['deliveries', 'tariffs']);
        return $this->buildQuery($model);
    }

    protected function getColumns()
    {
        return [
            Column::make('code')->title('Code abrégé')->width(100),
            Column::make('name')->title('Nom'),
            Column::make('deliveries_count')->title('#Distrib')->searchable(false)->class('text-right'),
            Column::make('tariffs_count')->title('#Tarifs')->searchable(false)->class('text-right'),
            $this->makeColumnButtons(),
        ];
    }
}
