[Bug] On relation in HTML Builder
This commit is contained in:
@@ -8,30 +8,25 @@ use App\Models\Botanic\Family;
|
||||
|
||||
class FamiliesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Families';
|
||||
public $model_name = 'Families';
|
||||
|
||||
public function query(Family $model)
|
||||
{
|
||||
$model = $model::withCount(['genres','species','varieties']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
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),
|
||||
Column::make('species_count')->title('Nb espèces')->searchable(false),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->searchable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
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(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,14 +22,10 @@ class GenresDataTable extends DataTable
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('latin'),
|
||||
Column::make('family.name'),
|
||||
Column::make('species_count')->title('Nb Espèces')->searchable(false),
|
||||
Column::make('varieties_count')->title('Nb Variétés')->searchable(false),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
Column::make('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(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,10 @@ class SpeciesDataTable extends DataTable
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('alias'),
|
||||
Column::make('genre.name'),
|
||||
Column::make('genre.name')->title('Genre'),
|
||||
Column::make('latin'),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,25 +8,21 @@ use App\Models\Botanic\Variety;
|
||||
|
||||
class VarietiesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Varieties';
|
||||
public $model_name = 'Varieties';
|
||||
|
||||
public function query(Variety $model)
|
||||
{
|
||||
$model = $model::with('specie');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
public function query(Variety $model)
|
||||
{
|
||||
$model = $model::with('specie');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('specie_name')->title('Espèce'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('specie.name')->title('Espèce'),
|
||||
Column::make('name')->title('Nom'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ class ParentDataTable extends DataTable
|
||||
*/
|
||||
public function dataTable($query)
|
||||
{
|
||||
$datatables = datatables()->eloquent($query);
|
||||
return self::addButtons($datatables);
|
||||
return $this->addButtons(datatables()->eloquent($query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,18 +29,28 @@ class ParentDataTable extends DataTable
|
||||
*/
|
||||
public function addButtons($datatables)
|
||||
{
|
||||
$buttons = self::getHtmlButtons();
|
||||
return $datatables->addColumn('action', $buttons);
|
||||
return $datatables->addColumn('action', $this->getHtmlButtons());
|
||||
}
|
||||
|
||||
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 = '';
|
||||
// $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 $buttons;
|
||||
}
|
||||
|
||||
public function makeColumnButtons()
|
||||
{
|
||||
return Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->searchable(false)
|
||||
->width(80)
|
||||
->addClass('text-center');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query source of dataTable.
|
||||
*
|
||||
@@ -61,7 +70,7 @@ class ParentDataTable extends DataTable
|
||||
*/
|
||||
public function html()
|
||||
{
|
||||
return self::buildHtml(strtolower($this->model_name) . '-table');
|
||||
return $this->buildHtml(strtolower($this->model_name) . '-table');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,11 +21,7 @@ class ArticleAttributeFamiliesDataTable extends DataTable
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('values_count')->title('Nb valeurs')->searchable(false),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,9 @@ class ArticleAttributeValuesDataTable extends DataTable
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('attribute_family.name')->title('Famille d\'attributs'),
|
||||
Column::make('attribute_family.name')->title('Famille d\'attributs') ,
|
||||
Column::make('value'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,23 +8,23 @@ use App\Models\Shop\ArticleFamily;
|
||||
|
||||
class ArticleFamiliesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'ArticleFamilies';
|
||||
public $model_name = 'ArticleFamilies';
|
||||
|
||||
public function query(ArticleFamily $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
public function query(ArticleFamily $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,11 +20,7 @@ class ArticlePricessDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,23 +8,19 @@ use App\Models\Shop\Article;
|
||||
|
||||
class ArticlesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Articles';
|
||||
public $model_name = 'Articles';
|
||||
|
||||
public function query(Article $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
public function query(Article $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,23 +8,19 @@ use App\Models\Shop\Category;
|
||||
|
||||
class CategoriesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Categories';
|
||||
public $model_name = 'Categories';
|
||||
|
||||
public function query(Category $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
public function query(Category $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,23 +8,19 @@ use App\Models\Shop\Customer;
|
||||
|
||||
class CustomersDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Customers';
|
||||
public $model_name = 'Customers';
|
||||
|
||||
public function query(Product $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
public function query(Product $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,23 +8,19 @@ use App\Models\Shop\Invoice;
|
||||
|
||||
class InvoicesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Invoices';
|
||||
public $model_name = 'Invoices';
|
||||
|
||||
public function query(Product $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
public function query(Product $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,23 +8,19 @@ use App\Models\Shop\Order;
|
||||
|
||||
class OrdersDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Orders';
|
||||
public $model_name = 'Orders';
|
||||
|
||||
public function query(Product $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
public function query(Product $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user