filter options
This commit is contained in:
parent
e4b3031354
commit
9dc63ca5d9
|
|
@ -3,6 +3,7 @@
|
|||
namespace Sarga\Admin\Http\Controllers;
|
||||
|
||||
use Sarga\Admin\DataGrids\OrderDataGrid;
|
||||
use Sarga\Shop\Models\Order;
|
||||
use Sarga\Shop\Repositories\OrderItemRepository;
|
||||
use Sarga\Shop\Repositories\OrderRepository;
|
||||
use Webkul\Admin\Http\Controllers\Sales\OrderController;
|
||||
|
|
@ -68,4 +69,16 @@ class Orders extends OrderController
|
|||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function accept($orderId){
|
||||
$order = $this->orderRepository->findOrFail($orderId);
|
||||
$this->orderRepository->updateOrderStatus($order, Order::STATUS_PURCHASE);
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function ship($orderId){
|
||||
$order = $this->orderRepository->findOrFail($orderId);
|
||||
$this->orderRepository->updateOrderStatus($order, Order::STATUS_SHIPPING);
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,8 @@ return [
|
|||
'title' => 'Orders',
|
||||
'view-title' => 'Order #:order_id',
|
||||
'cancel-btn-title' => 'Cancel',
|
||||
'accept-btn-title' => 'Accept',
|
||||
'ship-btn-title' => 'Cargo',
|
||||
'shipment-btn-title' => 'Ship',
|
||||
'invoice-btn-title' => 'Invoice',
|
||||
'info' => 'Information',
|
||||
|
|
|
|||
|
|
@ -26,8 +26,21 @@
|
|||
<a href="{{ route('admin.sales.orders.cancel', $order->id) }}" class="btn btn-lg btn-primary" v-alert:message="'{{ __('admin::app.sales.orders.cancel-confirm-msg') }}'">
|
||||
{{ __('admin::app.sales.orders.cancel-btn-title') }}
|
||||
</a>
|
||||
|
||||
@endif
|
||||
|
||||
@if ($order->canAccept())
|
||||
|
||||
<a href="{{ route('admin.sales.orders.accept', $order->id) }}" class="btn btn-lg btn-primary" >
|
||||
{{ __('admin::app.sales.orders.accept-btn-title') }}
|
||||
</a>
|
||||
@endif
|
||||
@if ($order->canSendShip())
|
||||
|
||||
<a href="{{ route('admin.sales.orders.ship', $order->id) }}" class="btn btn-lg btn-primary" >
|
||||
{{ __('admin::app.sales.orders.ship-btn-title') }}
|
||||
</a>
|
||||
@endif
|
||||
@if ($order->canInvoice() && $order->payment->method !== 'paypal_standard')
|
||||
<a href="{{ route('admin.sales.invoices.create', $order->id) }}" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.sales.orders.invoice-btn-title') }}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,18 @@ Route::group(['middleware' => ['web', 'admin'], 'prefix' => config('app.admin_ur
|
|||
'view' => 'admin::sales.orders.index',
|
||||
])->name('admin.sales.orders.index');
|
||||
|
||||
Route::get('/orders/view/{id}', [\Sarga\Admin\Http\Controllers\Orders::class, 'view'])->defaults('_config', [
|
||||
'view' => 'admin::sales.orders.view',
|
||||
])->name('admin.sales.orders.view');
|
||||
|
||||
Route::get('/orders/item/{id}/cancel', [\Sarga\Admin\Http\Controllers\Orders::class, 'cancelOrderItem'])
|
||||
->name('admin.sales.orders.cancel_item');
|
||||
|
||||
Route::post('/shipments/create/{order_id}', [\Sarga\Admin\Http\Controllers\Shipments::class, 'store'])->defaults('_config', [
|
||||
'redirect' => 'admin.sales.orders.view',
|
||||
])->name('admin.sales.shipments.store');
|
||||
|
||||
Route::get('/orders/{id}/accept',[\Sarga\Admin\Http\Controllers\Orders::class, 'accept'])->name('admin.sales.orders.accept');
|
||||
Route::get('/orders/{id}/ship',[\Sarga\Admin\Http\Controllers\Orders::class, 'ship'])->name('admin.sales.orders.ship');
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Contracts;
|
||||
|
||||
interface Order
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Models;
|
||||
|
||||
class Order extends \Webkul\Sales\Models\Order
|
||||
{
|
||||
public const STATUS_PURCHASE = 'purchase';
|
||||
|
||||
public const STATUS_SHIPPING = 'shipping';
|
||||
|
||||
protected $statusLabel = [
|
||||
self::STATUS_PENDING => 'Pending',
|
||||
self::STATUS_PENDING_PAYMENT => 'Pending Payment',
|
||||
self::STATUS_PROCESSING => 'Arrived',
|
||||
self::STATUS_COMPLETED => 'Completed',
|
||||
self::STATUS_CANCELED => 'Canceled',
|
||||
self::STATUS_CLOSED => 'Closed',
|
||||
self::STATUS_FRAUD => 'Fraud',
|
||||
self::STATUS_PURCHASE => 'Purchasing',
|
||||
self::STATUS_SHIPPING => 'Shipping',
|
||||
];
|
||||
|
||||
public function canSendShip(){
|
||||
return $this->status === self::STATUS_PURCHASE;
|
||||
}
|
||||
|
||||
public function canAccept(){
|
||||
return $this->status === self::STATUS_PENDING;
|
||||
}
|
||||
/**
|
||||
* Checks if new invoice is allow or not
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canInvoice(): bool{
|
||||
return $this->status === self::STATUS_SHIPPING && parent::canInvoice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if new shipment is allow or not
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canShip(): bool{
|
||||
return $this->status === self::STATUS_SHIPPING && parent::canShip();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class OrderProxy extends ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -11,5 +11,6 @@ class ModuleServiceProvider extends CoreModuleServiceProvider
|
|||
\Sarga\Shop\Models\Menu::class,
|
||||
\Sarga\Shop\Models\Vendor::class,
|
||||
\Sarga\Shop\Models\MenuTranslation::class,
|
||||
\Sarga\Shop\Models\Order::class,
|
||||
];
|
||||
}
|
||||
|
|
@ -7,6 +7,15 @@ use Webkul\Sales\Repositories\OrderRepository as WOrderRepository;
|
|||
|
||||
class OrderRepository extends WOrderRepository
|
||||
{
|
||||
/**
|
||||
* Specify model class name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function model(): string
|
||||
{
|
||||
return 'Sarga\Shop\Contracts\Order';
|
||||
}
|
||||
/**
|
||||
* Update order status.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue