28 lines
845 B
PHP
28 lines
845 B
PHP
<?php
|
|
|
|
namespace Modules\Core\Order\Services;
|
|
|
|
use Lunar\Models\Order;
|
|
use Modules\Core\Order\Models\OrderStatusTransition;
|
|
|
|
/**
|
|
* The single place every order_status_transitions row gets written —
|
|
* called by Modules\Core\Order\Listeners\RecordStatusTransition, itself
|
|
* listening to Modules\Core\Order\Events\OrderStatusChanged and
|
|
* OrderPaidChanged, dispatched by Modules\Core\Order\Services\
|
|
* OrderStatusWriter (the only writer of Order::status/paid left in this
|
|
* package).
|
|
*/
|
|
final class OrderStatusTransitionRecorder
|
|
{
|
|
public function record(Order $order, ?string $from, string $to, string $eventClass): void
|
|
{
|
|
OrderStatusTransition::create([
|
|
'order_id' => $order->id,
|
|
'from_status' => $from,
|
|
'to_status' => $to,
|
|
'event_class' => $eventClass,
|
|
]);
|
|
}
|
|
}
|