Refactoring, change menu, add many features
This commit is contained in:
@@ -30,7 +30,7 @@ class ArticlesDataTable extends DataTable
|
||||
{
|
||||
$datatables
|
||||
->editColumn('thumb', function (Article $article) {
|
||||
return Articles::getThumbSrc($article->image);
|
||||
return '<img src="' . Articles::getThumbSrc($article->image) . '">';
|
||||
})
|
||||
->rawColumns(['thumb','action']);
|
||||
return parent::modifier($datatables);
|
||||
@@ -41,7 +41,7 @@ class ArticlesDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('article_nature.name')->title('Nature'),
|
||||
Column::make('thumb')->searchable(false),
|
||||
Column::make('thumb')->searchable(false)->width(40)->class('text-center'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('tags_count')->title('Tags')->class('text-right')->searchable(false),
|
||||
Column::make('categories_count')->title('Rayons')->class('text-right')->searchable(false),
|
||||
|
||||
41
app/Datatables/Shop/DeliveriesDataTable.php
Normal file
41
app/Datatables/Shop/DeliveriesDataTable.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Delivery;
|
||||
|
||||
class DeliveriesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'deliveries';
|
||||
|
||||
public function query(Delivery $model)
|
||||
{
|
||||
$model = $model->with('SaleChannel');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('active', function (Delivery $delivery) {
|
||||
return view("components.form.toggle", ['value' => $delivery->active, 'on' => __('active'), 'off' => __('inactive'), 'meta' => 'data-id='.$delivery->id, 'size' => 'sm']);
|
||||
})
|
||||
->rawColumns(['active', 'action']);
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('active')->title(__('active'))->width(60)->class('text-center'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('sale_channel.name')->title(__('shop.sale_channels.name')),
|
||||
Column::make('address')->title('Adresse'),
|
||||
Column::make('zipcode')->title('Code postal'),
|
||||
Column::make('city')->title('Ville'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ class PackagesDataTable extends DataTable
|
||||
|
||||
public function query(Package $model)
|
||||
{
|
||||
$model = $model->withCount(['variations','offers']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
@@ -19,6 +20,8 @@ class PackagesDataTable extends DataTable
|
||||
{
|
||||
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'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -12,13 +12,16 @@ class SaleChannelsDataTable extends DataTable
|
||||
|
||||
public function query(SaleChannel $model)
|
||||
{
|
||||
$model = $model->withCount('deliveries');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('code')->title('Code abrégé')->width(100),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('deliveries_count')->title(__('shop.deliveries.list'))->searchable(false),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user