mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-22 22:13:57 +00:00
8a28eb1790
This reverts merge request !5
76 lines
1.5 KiB
PHP
76 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Orders\Steps;
|
|
|
|
|
|
use App\Models\Order;
|
|
use App\Models\OrderStep;
|
|
use Illuminate\Http\Request;
|
|
|
|
abstract class AbstractOrderStep
|
|
{
|
|
/** @var string */
|
|
protected $orderId;
|
|
|
|
/** @var string */
|
|
protected $currentStep;
|
|
|
|
/** @var null|string */
|
|
protected $nextStep;
|
|
|
|
/**
|
|
* AbstractOrderStep constructor.
|
|
* @param string $orderId
|
|
* @param Request|null $request
|
|
*/
|
|
public function __construct(string $orderId, ?Request $request = null)
|
|
{
|
|
$this->orderId = $orderId;
|
|
$this->currentStep = $this->getCurrentStep();
|
|
$this->currentStep = $this->getCurrentStep();
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getOrderId(): string
|
|
{
|
|
return $this->orderId;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getCurrentStep(): string
|
|
{
|
|
return Order::findOrFail($this->getOrderId())->current_step;
|
|
}
|
|
|
|
/**
|
|
* @param string $currentStep
|
|
*/
|
|
public function setCurrentStep(string $currentStep): void
|
|
{
|
|
$this->currentStep = $currentStep;
|
|
}
|
|
|
|
/**
|
|
* @return null|string
|
|
*/
|
|
public function getNextStep(): ?string
|
|
{
|
|
$nextStep = OrderStep::where('order_id', $this->getOrderId())
|
|
->where('complete', 0)->orderBy('sequence')->first();
|
|
return $nextStep ? $nextStep->reference_id : null;
|
|
}
|
|
|
|
/**
|
|
* @param null|string $nextStep
|
|
*/
|
|
public function setNextStep(?string $nextStep): void
|
|
{
|
|
$this->nextStep = $nextStep;
|
|
}
|
|
|
|
|
|
} |