31 lines
859 B
PHP
31 lines
859 B
PHP
<?php
|
|
|
|
namespace App\Datatables\Botanic;
|
|
|
|
use Yajra\DataTables\Html\Column;
|
|
use App\Datatables\ParentDataTable as DataTable;
|
|
use App\Models\Botanic\Variety;
|
|
|
|
class VarietiesDataTable extends DataTable
|
|
{
|
|
public $model_name = 'varieties';
|
|
|
|
public function query(Variety $model)
|
|
{
|
|
// $model = $model::with('specie')->withCount('Articles')->select('botanic_varieties.*');
|
|
$model = $model::joinRelations('Specie')->select('botanic_varieties.*','botanic_species.name as specie_name')->with('Specie')->withCount('Articles');
|
|
return self::buildQuery($model);
|
|
}
|
|
|
|
protected function getColumns()
|
|
{
|
|
return [
|
|
Column::make('Specie.name')->data('specie_name')->title('Espèce'),
|
|
Column::make('name')->title('Nom'),
|
|
Column::make('articles_count')->title('Nb articles')->class('text-right')->searchable(false),
|
|
self::makeColumnButtons(),
|
|
];
|
|
}
|
|
|
|
}
|