<?php

namespace App\Datatables\Admin\Shop;

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

class PackagesDataTable extends DataTable
{
    public $model_name = 'packages';

    public function query(Package $model)
    {
        $model = $model->withCount(['variations', 'offers']);

        return $this->buildQuery($model);
    }

    protected function getColumns()
    {
        return [
            Column::make('value')->title('Valeur'),
            Column::make('variations_count')->title('nb variations')->searchable(false)->class('text-right'),
            Column::make('offers_count')->title('nb offres')->searchable(false)->class('text-right'),
            $this->makeColumnButtons(),
        ];
    }
}
