Skip to content

Commit

Permalink
Fix, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Jan 23, 2024
1 parent 6c7e99b commit e2a5a2e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/GaletteAuto/Autos.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function removeVehicles(int|array $ids): bool
$infos = null;
foreach ($vehicles as $vehicle) {
$str_v = $vehicle->id_car . ' - ' . $vehicle->car_name .
' (' . $vehicle->brand . ' ' . $vehicle->model . ')';
' (' . $vehicle->brand->brand . ' ' . $vehicle->model->model . ')';
$infos .= $str_v . "\n";

$p = new Picture($this->plugins, $vehicle->id_car);
Expand Down
6 changes: 3 additions & 3 deletions lib/GaletteAuto/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ public function showAddEditVehicle(Request $request, Response $response, string
'require_calendar' => true,
'require_dialog' => true,
'car' => $auto,
'models' => $models->getList((int)$auto->model->brand),
'js_init_models' => (($auto->model->brand != '') ? false : true),
'brands' => $auto->model->obrand->getList(),
'models' => $models->getList($auto->model->brand->id),
'js_init_models' => !isset($auto->model->brand),
'brands' => $auto->model->brand->getList(),
'colors' => $auto->color->getList(),
'bodies' => $auto->body->getList(),
'transmissions' => $auto->transmission->getList(),
Expand Down
31 changes: 3 additions & 28 deletions lib/GaletteAuto/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
*
* @property integer $id
* @property string $model
* @property int $brand
* @property Brand $obrand
* @property Brand $brand
*/
class Model
{
Expand Down Expand Up @@ -208,23 +207,7 @@ public function delete(array $ids): bool
*/
public function __get(string $name)
{
$forbidden = array();
if (!in_array($name, $forbidden)) {
switch ($name) {
case 'brand':
return $this->brand->id;
case 'obrand':
return $this->brand;
default:
return $this->$name;
}
} else {
Analog::log(
'[' . get_class($this) . '] Unable to retrieve `' . $name . '`',
Analog::INFO
);
return false;
}
return $this->$name;
}

/**
Expand All @@ -237,15 +220,7 @@ public function __get(string $name)
*/
public function __isset(string $name): bool
{
$knowns = [
'obrand'
];

if (in_array($name, $knowns) || property_exists($this, $name)) {
return true;
}

return false;
return property_exists($this, $name);
}

/**
Expand Down

0 comments on commit e2a5a2e

Please sign in to comment.