Make mobile api use vehicle model formatting method #128

This commit is contained in:
Kendrick Chan 2018-05-23 19:06:47 +08:00
parent a7f5a85e65
commit 82fc9f3948
2 changed files with 9 additions and 3 deletions

View file

@ -423,7 +423,8 @@ class APIController extends Controller
{ {
$vlist[] = [ $vlist[] = [
'id' => $v->getID(), 'id' => $v->getID(),
'make' => $v->getMake() . ' ' . $v->getModelYearFrom() . '-' . $v->getModelYearTo(), 'make' => trim($v->getMake() . ' ' . $v->getModelYearFormatted(false)),
// 'make' => $v->getMake() . ' ' . $v->getModelYearFrom() . '-' . $v->getModelYearTo(),
]; ];
} }

View file

@ -114,12 +114,17 @@ class Vehicle
return $this->model_year_to; return $this->model_year_to;
} }
public function getModelYearFormatted() public function getModelYearFormatted($has_dash = true)
{ {
if ($this->model_year_from == 0) if ($this->model_year_from == 0)
{ {
if ($this->model_year_to == 0) if ($this->model_year_to == 0)
return '-'; {
if ($has_dash)
return '-';
return '';
}
return $this->model_year_to; return $this->model_year_to;
} }