Fix assign rider so cancelled job orders cannot be assigned #175

This commit is contained in:
Kendrick Chan 2019-01-28 03:16:50 +08:00
parent 4b24454549
commit 1bd5c30875
2 changed files with 13 additions and 0 deletions

View file

@ -1142,6 +1142,11 @@ class JobOrderController extends BaseController
if (empty($obj))
throw $this->createNotFoundException('The item does not exist');
// check if we can assign
if (!$obj->canAssign())
throw $this->createNotFoundException('Cannot assign rider to this job order.');
// check if lat and lng are provided
if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) {
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';

View file

@ -734,4 +734,12 @@ class JobOrder
return false;
}
public function canAssign()
{
if ($this->status == JOStatus::ASSIGNED)
return true;
return false;
}
}