Files
izyim/app/Classes/Modules/Orders/Steps/AbstractOrderStep.php
T
omair saleh 8a28eb1790 Revert "Merge branch 'dashboardReport' into 'master'"
This reverts merge request !5
2019-03-19 09:57:38 +00:00

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;
}
}