Fix typo
This commit is contained in:
32
app/Datatables/Botanic/FamiliesDataTable.php
Normal file
32
app/Datatables/Botanic/FamiliesDataTable.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Botanic;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Botanic\Family;
|
||||
|
||||
class FamiliesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'families';
|
||||
|
||||
public function query(Family $model)
|
||||
{
|
||||
$model = $model::withCount(['genres','species','varieties']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('latin'),
|
||||
Column::make('genres_count')->title('Nb genres')->searchable(false)->addClass('text-right'),
|
||||
Column::make('species_count')->title('Nb espèces')->searchable(false)->addClass('text-right'),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
43
app/Datatables/Botanic/GenresDataTable.php
Normal file
43
app/Datatables/Botanic/GenresDataTable.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Botanic;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Botanic\Genre;
|
||||
|
||||
class GenresDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'genres';
|
||||
|
||||
public function query(Genre $model)
|
||||
{
|
||||
$model = $model::with('family')->withCount('species')->withCount('varieties');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('family_name', function(Genre $genre) {
|
||||
return $genre->family ? $genre->family->name : '';
|
||||
})
|
||||
->rawColumns(['genre_name', 'action'])
|
||||
;
|
||||
return Parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('latin'),
|
||||
Column::make('family.name')->data('family_name')->title('Famille'),
|
||||
Column::make('species_count')->title('Nb Espèces')->searchable(false)->addClass('text-right'),
|
||||
Column::make('varieties_count')->title('Nb Variétés')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
43
app/Datatables/Botanic/SpeciesDataTable.php
Normal file
43
app/Datatables/Botanic/SpeciesDataTable.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Botanic;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Botanic\Specie;
|
||||
|
||||
class SpeciesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'species';
|
||||
|
||||
public function query(Specie $model)
|
||||
{
|
||||
$model = $model::withCount('varieties')->with('genre');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('genre_name', function(Specie $specie) {
|
||||
return $specie->genre ? $specie->genre->name : '';
|
||||
})
|
||||
->rawColumns(['genre_name', 'action'])
|
||||
;
|
||||
return Parent::modifier($datatables);
|
||||
}
|
||||
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('genre.name')->data('genre_name')->title('Genre'),
|
||||
Column::make('latin'),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Datatables/Botanic/VarietiesDataTable.php
Normal file
30
app/Datatables/Botanic/VarietiesDataTable.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user