Add varieties
This commit is contained in:
@@ -12,18 +12,21 @@ class FamiliesDataTable extends DataTable
|
||||
|
||||
public function query(Family $model)
|
||||
{
|
||||
$model = $model::withCount('genres');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('latin'),
|
||||
Column::make('genres_count')->title('Nb genres'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->searchable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
|
||||
@@ -12,15 +12,18 @@ class GenresDataTable extends DataTable
|
||||
|
||||
public function query(Genre $model)
|
||||
{
|
||||
$model = $model::with('family')->withCount('species');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('latin'),
|
||||
Column::make('family.name'),
|
||||
Column::make('species_count')->title('Nb Espèces'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
|
||||
@@ -29,11 +29,17 @@ class ParentDataTable extends DataTable
|
||||
* @return \Yajra\DataTables\DataTableAbstract
|
||||
*/
|
||||
public function addButtons($datatables)
|
||||
{
|
||||
$buttons = self::getHtmlButtons();
|
||||
return $datatables->addColumn('action', $buttons);
|
||||
}
|
||||
|
||||
public function getHtmlButtons()
|
||||
{
|
||||
$buttons = '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-secondary btn-show mr-2"><i class="fa fa-fw fa-eye"></i></button>';
|
||||
$buttons .= '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-primary btn-edit mr-2"><i class="fa fa-fw fa-edit"></i></button>';
|
||||
$buttons .= '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-danger btn-del"><i class="fa fa-fw fa-trash"></i></button>';
|
||||
return $datatables->addColumn('action', $buttons);
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
32
app/Datatables/VarietiesDataTable.php
Normal file
32
app/Datatables/VarietiesDataTable.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\DataTables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Variety;
|
||||
|
||||
class VarietiesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Varieties';
|
||||
|
||||
public function query(Variety $model)
|
||||
{
|
||||
$model = $model::with('specie');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('specie_name'),
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user