Added approve action to order view

This commit is contained in:
Deon George
2019-01-24 17:16:51 +11:00
parent b19f01d7a4
commit 95bd89aa93
3 changed files with 23 additions and 17 deletions

View File

@@ -56,7 +56,7 @@ class Service extends Model
];
private $valid_status = [
'ORDER-SUBMIT' => ['accept'=>'ORDER-SENT','reject'=>'ORDER-REJECTED'],
'ORDER-SUBMIT' => ['approve'=>'ORDER-SENT','reject'=>'ORDER-REJECTED'],
];
public function account()
@@ -167,9 +167,13 @@ class Service extends Model
/**
* This function will present the Order Info Details
*/
public function getOrderInfoDetailsAttribute()
public function getOrderInfoDetailsAttribute(): string
{
if (! $this->order_info)
return '';
$result = '';
foreach ($this->order_info as $k=>$v)
$result .= sprintf('%s: <b>%s</b><br>',ucfirst($k),$v);
@@ -222,17 +226,16 @@ class Service extends Model
return $this->active OR ($this->order_status AND ! in_array($this->order_status,$this->inactive_status));
}
public function nextStatus() {
switch ($this->order_status)
public function nextStatus(string $status) {
if ($x=$this->validStatus($status))
{
case 'ORDER-REQUEST':
$this->order_status = 'ORDER-SENT';
$this->save();
return $this;
$this->order_status = $x;
$this->save();
default:
abort(500,'Next Status not set up for:'.$this->order_status);
return $this;
}
abort(500,'Next Status not set up for:'.$this->order_status);
}
/**