refactoring of admin datatables
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\ArticleNature;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Article;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Delivery;
|
||||
@@ -29,10 +29,16 @@ class DeliveriesDataTable extends DataTable
|
||||
'size' => 'sm',
|
||||
]);
|
||||
})
|
||||
->editColumn('is_public', function (Delivery $delivery) {
|
||||
return $delivery->is_public ? "<i class='fa fa-check secondary'></i>" : '';
|
||||
})
|
||||
->editColumn('at_house', function (Delivery $delivery) {
|
||||
return $delivery->at_house ? "<i class='fa fa-check secondary'></i>" : '';
|
||||
})
|
||||
->editColumn('address', function (Delivery $delivery) {
|
||||
return $delivery->address.' '.$delivery->zipcode.' '.$delivery->city;
|
||||
})
|
||||
->rawColumns(['active', 'address', 'action']);
|
||||
->rawColumns(['active', 'is_public', 'at_house', 'address', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
@@ -41,6 +47,8 @@ class DeliveriesDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('active')->title(__('active'))->width(60)->class('text-center'),
|
||||
Column::make('is_public')->title(__('Public'))->width(60)->class('text-center'),
|
||||
Column::make('at_house')->title(__('Défaut'))->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')->searchable(false),
|
||||
49
app/Datatables/Admin/Shop/InvoicesDataTable.php
Normal file
49
app/Datatables/Admin/Shop/InvoicesDataTable.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Invoice;
|
||||
use App\Repositories\Shop\Invoices;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class InvoicesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'Invoices';
|
||||
|
||||
public function query(Invoice $model)
|
||||
{
|
||||
$model = $model->with('customer');
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('status', function (Invoice $invoice) {
|
||||
return Invoices::getStatus($invoice->status);
|
||||
})
|
||||
->editColumn('created_at', function (Invoice $invoice) {
|
||||
return $invoice->created_at->toDateTimeString();
|
||||
})
|
||||
->editColumn('customer.last_name', function (Invoice $invoice) {
|
||||
return ($invoice->customer ?? false) ? $invoice->customer->last_name.' '.$invoice->customer->first_name : '';
|
||||
})
|
||||
->rawColumns(['action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('ref')->title('Ref')->width(80),
|
||||
Column::make('status')->width(60),
|
||||
Column::make('created_at')->title('Date')->width(100),
|
||||
Column::make('customer.last_name')->title('Client')->default(''),
|
||||
Column::make('total')->addClass('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Offer;
|
||||
61
app/Datatables/Admin/Shop/OrdersDataTable.php
Normal file
61
app/Datatables/Admin/Shop/OrdersDataTable.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Order;
|
||||
use App\Repositories\Shop\InvoicePayments;
|
||||
use App\Repositories\Shop\Orders;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class OrdersDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'orders';
|
||||
|
||||
public $sortedColumn = 1;
|
||||
|
||||
public $sortedOrder = 'desc';
|
||||
|
||||
public $stateSave = true;
|
||||
|
||||
public function query(Order $model)
|
||||
{
|
||||
$model = $model->with(['customer', 'delivery']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('status', function (Order $order) {
|
||||
return Orders::getStatus($order->status);
|
||||
})
|
||||
->editColumn('created_at', function (Order $order) {
|
||||
return $order->created_at->toDateTimeString();
|
||||
})
|
||||
->editColumn('customer.last_name', function (Order $order) {
|
||||
return $order->customer->last_name.' '.$order->customer->first_name;
|
||||
})
|
||||
->editColumn('payment_type', function (Order $order) {
|
||||
return InvoicePayments::getPaymentType($order->payment_type);
|
||||
})
|
||||
->rawColumns(['action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('ref')->title('Ref'),
|
||||
Column::make('status')->title('Statut'),
|
||||
Column::make('created_at')->title('Date'),
|
||||
Column::make('customer.last_name')->title('Client'),
|
||||
Column::make('delivery.name')->title('Point de distribution'),
|
||||
Column::make('payment_type')->title('Règlement'),
|
||||
Column::make('total_shipped')->title('Montant')->class('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
namespace App\Datatables\Admin\Shop;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\SaleChannel;
|
||||
@@ -45,6 +45,11 @@ class OrdersDataTable extends DataTable
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
public function getHtmlButtons()
|
||||
{
|
||||
return self::getButtonShow();
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user