48 lines
1.9 KiB
PHP
48 lines
1.9 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace Modules\Core\Providers;
|
||
|
|
|
||
|
|
use Illuminate\Support\Facades\Event;
|
||
|
|
use Illuminate\Support\ServiceProvider;
|
||
|
|
use Lunar\Models\Order;
|
||
|
|
use Lunar\Models\Transaction;
|
||
|
|
use Modules\Core\Notification\NotificationRegistry;
|
||
|
|
use Modules\Core\Order\Listeners\DeriveOrderDeliveredFromShipment;
|
||
|
|
use Modules\Core\Order\Notifications\OrderCapturedNotification;
|
||
|
|
use Modules\Core\Order\Notifications\OrderDeliveredNotification;
|
||
|
|
use Modules\Core\Order\Notifications\OrderRefundedNotification;
|
||
|
|
use Modules\Core\Order\Notifications\OrderStatusUpdatedNotification;
|
||
|
|
use Modules\Core\Order\Observers\OrderObserver;
|
||
|
|
use Modules\Core\Order\Observers\TransactionObserver;
|
||
|
|
use Modules\Core\Order\Support\OrderStatus;
|
||
|
|
use Modules\Core\Shipping\Events\ShipmentStatusUpdatedByCarrier;
|
||
|
|
|
||
|
|
class OrderServiceProvider extends ServiceProvider
|
||
|
|
{
|
||
|
|
public function boot(): void
|
||
|
|
{
|
||
|
|
Order::observe(OrderObserver::class);
|
||
|
|
Transaction::observe(TransactionObserver::class);
|
||
|
|
|
||
|
|
Order::macro('paymentStatus', fn () => OrderStatus::payment($this));
|
||
|
|
Order::macro('fulfillmentStatus', fn () => OrderStatus::fulfillment($this));
|
||
|
|
|
||
|
|
Event::listen(ShipmentStatusUpdatedByCarrier::class, DeriveOrderDeliveredFromShipment::class);
|
||
|
|
|
||
|
|
NotificationRegistry::get()->register([
|
||
|
|
OrderDeliveredNotification::class,
|
||
|
|
OrderStatusUpdatedNotification::class,
|
||
|
|
OrderRefundedNotification::class,
|
||
|
|
OrderCapturedNotification::class,
|
||
|
|
]);
|
||
|
|
|
||
|
|
// Lets the consuming app override copy/markup without forking core
|
||
|
|
// — published into resources/views/vendor/core/order/notifications,
|
||
|
|
// which loadViewsFrom() (CoreServiceProvider) already resolves
|
||
|
|
// ahead of the package's own views for the `core::` namespace.
|
||
|
|
$this->publishes([
|
||
|
|
__DIR__ . '/../../resources/views/order/notifications' => resource_path('views/vendor/core/order/notifications'),
|
||
|
|
], 'core-views');
|
||
|
|
}
|
||
|
|
}
|