refactor datatables admin
This commit is contained in:
74
app/Datatables/Admin/Shop/CategoriesDataTable.php
Normal file
74
app/Datatables/Admin/Shop/CategoriesDataTable.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Category;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class CategoriesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'categories';
|
||||
|
||||
public function query(Category $model)
|
||||
{
|
||||
$model = $model::notRoot()->with(['tags.articles'])->withCount(['articles', 'tags']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('name', function (Category $category) {
|
||||
return $category->name;
|
||||
})
|
||||
->editColumn('visible', function (Category $category) {
|
||||
return view('components.form.toggle', [
|
||||
'name' => 'visible',
|
||||
'value' => $category->visible,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id='.$category->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'visible',
|
||||
]);
|
||||
})
|
||||
->editColumn('homepage', function (Category $category) {
|
||||
return view('components.form.toggle', [
|
||||
'name' => 'homepage',
|
||||
'value' => $category->homepage,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id='.$category->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'homepage',
|
||||
]);
|
||||
})
|
||||
->editColumn('articles_tagged_count', function (Category $category) {
|
||||
$count = 0;
|
||||
foreach ($category->tags as $tag) {
|
||||
$nb = collect($tag->articles)->count();
|
||||
$count += $nb;
|
||||
}
|
||||
|
||||
return $count;
|
||||
})
|
||||
->rawColumns(['visible', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('visible')->title('visible')->width(60),
|
||||
Column::make('homepage')->title('homepage')->width(60),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('articles_count')->title('#Art')->class('text-right')->orderable(false)->searchable(false)->width(60),
|
||||
Column::make('tags_count')->title('#Tags')->class('text-right')->searchable(false)->width(60),
|
||||
Column::make('articles_tagged_count')->title('#ArtTag')->class('text-right')->searchable(false)->orderable(false)->width(60),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Datatables/Admin/Shop/CustomerAddressesDataTable.php
Normal file
32
app/Datatables/Admin/Shop/CustomerAddressesDataTable.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\CustomerAddress;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class CustomerAddressesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'customer_addresses';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = route('Admin.Shop.CustomerAddresses.index');
|
||||
}
|
||||
|
||||
public function query(CustomerAddress $model)
|
||||
{
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('address')->title('Adresse'),
|
||||
Column::make('zipcode')->title('Code postal'),
|
||||
Column::make('city')->title('Ville'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Datatables/Admin/Shop/CustomersDataTable.php
Normal file
34
app/Datatables/Admin/Shop/CustomersDataTable.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Customer;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class CustomersDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'customers';
|
||||
|
||||
public function query(Customer $model)
|
||||
{
|
||||
$model = $model->with('addresses');
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('company')->title('Société'),
|
||||
Column::make('last_name')->title('Nom'),
|
||||
Column::make('first_name')->title('Prénom'),
|
||||
Column::make('address')->title('Adresse'),
|
||||
Column::make('zipcode')->title('Code postal'),
|
||||
Column::make('city')->title('Ville'),
|
||||
Column::make('phone')->title('Téléphone'),
|
||||
Column::make('email')->title('Email'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Datatables/Admin/Shop/DeliveryPackagesDataTable.php
Normal file
27
app/Datatables/Admin/Shop/DeliveryPackagesDataTable.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\DeliveryPackage;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class DeliveryPackagesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'delivery_packages';
|
||||
|
||||
public function query(DeliveryPackage $model)
|
||||
{
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('weight')->title('Poids')->addClass('text-right'),
|
||||
Column::make('weight_flyer')->title('Flyer')->addClass('text-right'),
|
||||
Column::make('weight_packaging')->title('Packaging')->addClass('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\DeliveryTypeCalculation;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class DeliveryTypeCalculationsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'delivery_type_calculations';
|
||||
|
||||
public function query(DeliveryTypeCalculation $model)
|
||||
{
|
||||
$model = $model->with('delivery_type');
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('delivery_type.name')->title('Nom'),
|
||||
Column::make('weight')->title('Poids en g')->addClass('text-right'),
|
||||
Column::make('price')->title('Prix')->addClass('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
25
app/Datatables/Admin/Shop/DeliveryTypesDataTable.php
Normal file
25
app/Datatables/Admin/Shop/DeliveryTypesDataTable.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\DeliveryType;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class DeliveryTypesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'delivery_types';
|
||||
|
||||
public function query(DeliveryType $model)
|
||||
{
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Datatables/Admin/Shop/HomepagesDataTable.php
Normal file
32
app/Datatables/Admin/Shop/HomepagesDataTable.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Homepage;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class HomepagesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'homepages';
|
||||
|
||||
public function query(Homepage $model)
|
||||
{
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables->rawColumns(['text', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('text')->title('Texte'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
53
app/Datatables/Admin/Shop/MerchandisesDataTable.php
Normal file
53
app/Datatables/Admin/Shop/MerchandisesDataTable.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Merchandise;
|
||||
use App\Repositories\Shop\Merchandises;
|
||||
use App\Repositories\Shop\Tags;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class MerchandisesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'merchandises';
|
||||
|
||||
public function query(Merchandise $model)
|
||||
{
|
||||
$model = $model::with(['image', 'tags'])->withCount(['Articles', 'tags', 'images']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('thumb', function (Merchandise $merchandise) {
|
||||
return Merchandises::getThumb($merchandise->image, false);
|
||||
})
|
||||
->editColumn('tags2', function (Merchandise $merchandise) {
|
||||
$html = '';
|
||||
foreach ($merchandise->tags as $tag) {
|
||||
$html .= Tags::getTagHtml($tag);
|
||||
}
|
||||
|
||||
return $html;
|
||||
})
|
||||
->rawColumns(['thumb', 'tags2', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('thumb')->title('')->searchable(false)->orderable(false)->width(40)->class('text-center'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('tags2')->title('Tags')->searchable(false)->orderable(false),
|
||||
Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false),
|
||||
Column::make('tags_count')->title('#Tag')->class('text-right')->searchable(false),
|
||||
Column::make('images_count')->title('#Pho')->class('text-right')->searchable(false),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Datatables/Admin/Shop/PackagesDataTable.php
Normal file
29
app/Datatables/Admin/Shop/PackagesDataTable.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Package;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class PackagesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'packages';
|
||||
|
||||
public function query(Package $model)
|
||||
{
|
||||
$model = $model->withCount(['variations', 'offers']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
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'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\PriceGenericCategory;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class PriceGenericCategoriesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'price_generic_categories';
|
||||
|
||||
public function query(PriceGenericCategory $model)
|
||||
{
|
||||
$model = $model->withCount('price_generics');
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('price_generics_count')->title('Nb Tarifs')->class('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
58
app/Datatables/Admin/Shop/PriceListsDataTable.php
Normal file
58
app/Datatables/Admin/Shop/PriceListsDataTable.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\PriceList;
|
||||
use App\Repositories\Shop\PriceLists;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class PriceListsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'price_lists';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = route('Admin.Shop.PriceLists.index');
|
||||
}
|
||||
|
||||
public function query(PriceList $model)
|
||||
{
|
||||
$model = $model->with(['sale_channel', 'price_list_values']);
|
||||
$model = self::filterByTariff($model);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public static function filterByTariff($model, $tariff_id = false)
|
||||
{
|
||||
$tariff_id = $tariff_id ? $tariff_id : self::isFilteredByField('tariff_id');
|
||||
|
||||
return $tariff_id ? $model->byTariff($tariff_id) : $model;
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('status', function (PriceList $price_list) {
|
||||
return PriceLists::getStatus($price_list['status_id']);
|
||||
})
|
||||
->editColumn('tariff_id', function (PriceList $price_list) {
|
||||
return view('Admin.Shop.PriceLists.partials.table-prices', ['prices' => $price_list['price_list_values']]);
|
||||
})
|
||||
->rawColumns(['tariff_id', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('status_id')->data('status')->title('etat'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('sale_channel.name')->title('Canal de vente'),
|
||||
Column::make('tariff_id')->title('Liste de prix'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
53
app/Datatables/Admin/Shop/ProducersDataTable.php
Normal file
53
app/Datatables/Admin/Shop/ProducersDataTable.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Producer;
|
||||
use App\Repositories\Shop\Producers;
|
||||
use App\Repositories\Shop\Tags;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class ProducersDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'producers';
|
||||
|
||||
public function query(Producer $model)
|
||||
{
|
||||
$model = $model::with(['image', 'tags'])->withCount(['Merchandises', 'tags', 'images']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('thumb', function (Producer $producer) {
|
||||
return Producers::getThumb($producer->image, false);
|
||||
})
|
||||
->editColumn('tags2', function (Producer $producer) {
|
||||
$html = '';
|
||||
foreach ($producer->tags as $tag) {
|
||||
$html .= Tags::getTagHtml($tag);
|
||||
}
|
||||
|
||||
return $html;
|
||||
})
|
||||
->rawColumns(['thumb', 'tags2', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('thumb')->title('')->searchable(false)->orderable(false)->width(40)->class('text-center'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('tags2')->title('Tags')->searchable(false)->orderable(false),
|
||||
Column::make('merchandises_count')->title('#Mar')->class('text-right')->searchable(false),
|
||||
Column::make('tags_count')->title('#Tag')->class('text-right')->searchable(false),
|
||||
Column::make('images_count')->title('#Pho')->class('text-right')->searchable(false),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
51
app/Datatables/Admin/Shop/TagGroupsDataTable.php
Normal file
51
app/Datatables/Admin/Shop/TagGroupsDataTable.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\TagGroup;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class TagGroupsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'tag_groups';
|
||||
|
||||
public $sortedColumn = 2;
|
||||
|
||||
public function query(TagGroup $model)
|
||||
{
|
||||
$model = $model::with('article_family')->withCount('tags');
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('visible', function (TagGroup $tag_group) {
|
||||
return view('components.form.toggle', [
|
||||
'name' => 'visible',
|
||||
'value' => $tag_group->visible,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id='.$tag_group->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'visible',
|
||||
]);
|
||||
})
|
||||
->rawColumns(['visible', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('visible')->title('Visible')->width(60)->searchable(false),
|
||||
Column::make('code')->title('Code')->width(100),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('tags_count')->title('#Tags')->searchable(false)->addClass('text-right')->width(60),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
45
app/Datatables/Admin/Shop/TagsDataTable.php
Normal file
45
app/Datatables/Admin/Shop/TagsDataTable.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Tag;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class TagsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'tags';
|
||||
|
||||
public $rowReorder = ['selector' => 'tr'];
|
||||
|
||||
public function query(Tag $model)
|
||||
{
|
||||
$model = $model::with('tag_group')->withCount(['articles', 'shelves', 'species', 'varieties']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('name', function (Tag $tag) {
|
||||
return $tag->name;
|
||||
})
|
||||
->rawColumns(['active', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('tag_group.name')->title('Groupe')->width(200),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false)->width(60),
|
||||
Column::make('species_count')->title('#Esp')->class('text-right')->searchable(false)->width(60),
|
||||
Column::make('varieties_count')->title('#Var')->class('text-right')->searchable(false)->width(60),
|
||||
Column::make('shelves_count')->title('#Ray')->class('text-right')->searchable(false)->width(60),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
25
app/Datatables/Admin/Shop/TariffUnitiesDataTable.php
Normal file
25
app/Datatables/Admin/Shop/TariffUnitiesDataTable.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\TariffUnity;
|
||||
|
||||
class TariffUnitiesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'tariff_unities';
|
||||
|
||||
public function query(TariffUnity $model)
|
||||
{
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('value')->title('Valeur'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
53
app/Datatables/Admin/Shop/TariffsDataTable.php
Normal file
53
app/Datatables/Admin/Shop/TariffsDataTable.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Tariff;
|
||||
use App\Repositories\Shop\Tariffs;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class TariffsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'tariffs';
|
||||
|
||||
public function query(Tariff $model)
|
||||
{
|
||||
$model = $model->with(['sale_channels'])->withCount(['price_lists', 'offers']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('status', function (Tariff $tariff) {
|
||||
return Tariffs::getStatus($tariff['status_id']);
|
||||
})
|
||||
->editColumn('sale_channels2', function (Tariff $tariff) {
|
||||
$html = '';
|
||||
foreach ($tariff->sale_channels as $sale_channel) {
|
||||
$html .= $sale_channel->code.', ';
|
||||
}
|
||||
|
||||
return $html;
|
||||
})
|
||||
->rawColumns(['sale_channels2', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('status_id')->data('status')->title('status')->searchable(false)->orderable(false),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('sale_channels2')->title('Canaux de vente')->searchable(false)->orderable(false),
|
||||
Column::make('code')->title('Code'),
|
||||
Column::make('ref')->title('Référence'),
|
||||
Column::make('price_lists_count')->title('#Lst prix')->searchable(false)->orderable(false)->class('text-right'),
|
||||
Column::make('offers_count')->title('#Offres')->searchable(false)->orderable(false)->class('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
25
app/Datatables/Admin/Shop/UnitiesDataTable.php
Normal file
25
app/Datatables/Admin/Shop/UnitiesDataTable.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Unity;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class UnitiesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'unities';
|
||||
|
||||
public function query(Unity $model)
|
||||
{
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('value')->title('Valeur'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
42
app/Datatables/Admin/Shop/VariationsDataTable.php
Normal file
42
app/Datatables/Admin/Shop/VariationsDataTable.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Variation;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class VariationsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'variations';
|
||||
|
||||
public function query(Variation $model)
|
||||
{
|
||||
$model = $model->with(['package', 'unity'])->withCount('offers');
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('unity_value', function (Variation $variation) {
|
||||
return $variation->unity ? $variation->unity->value : '';
|
||||
})
|
||||
->rawColumns(['description', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('package.value')->title('Package'),
|
||||
Column::make('quantity')->title('Quantité')->class('text-right')->with(80),
|
||||
Column::make('unity_value')->title('Unité')->searchable(false)->with(80),
|
||||
Column::make('description')->title('Description'),
|
||||
Column::make('offers_count')->title('#Ofr')->searchable(false)->class('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user