Add support for vehicle reference field
Introduce a new "reference" field for vehicles to allow storing and validating additional information. Updates include parameter handling, validation, and database integration for creating, modifying, and retrieving the "reference" field.
This commit is contained in:
@@ -16,6 +16,7 @@ class customer_vehicles_o extends db
|
||||
public object_property $reg; // The registration number of the vehicle
|
||||
public object_property $wash_subscription; // The wash subscription of the vehicle (boolean)
|
||||
public object_property $notes; // The notes of the vehicle
|
||||
public object_property $reference; // The reference of the vehicle
|
||||
public object_property $deleted_at; // The timestamp of when the record was "deleted"
|
||||
|
||||
/**
|
||||
@@ -52,6 +53,7 @@ class customer_vehicles_o extends db
|
||||
'customer_name' => (string)(new users_o())->getCustomerName((int)$this->customer_id->value()),
|
||||
'type' => (int)$this->type->value(),
|
||||
'reg' => (string)$this->reg->value(),
|
||||
'reference' => ($this->reference->value() ? (string)$this->reference->value() : null),
|
||||
'wash_subscription' => $wash_subscription,
|
||||
'addons' => [
|
||||
'enabled' => count($addons),
|
||||
@@ -160,7 +162,7 @@ class customer_vehicles_o extends db
|
||||
/**
|
||||
* @throws Exception If the creation of the object fails
|
||||
*/
|
||||
public function add(int $customer_number, int $type, string $reg, bool $subscription): void
|
||||
public function add(int $customer_number, int $type, string $reg, bool $subscription, string|null $reference = null): void
|
||||
{
|
||||
global $db, $response;
|
||||
$tmp_id = self::add_object([
|
||||
@@ -168,6 +170,7 @@ class customer_vehicles_o extends db
|
||||
'type' => (int)$type,
|
||||
'reg' => (string)$reg,
|
||||
'wash_subscription' => (bool)$subscription ? 1 : 0,
|
||||
'reference' => ($reference ? (string)$reference : null),
|
||||
]);
|
||||
self::select((int)$tmp_id);
|
||||
self::objectChanged();
|
||||
@@ -189,6 +192,7 @@ class customer_vehicles_o extends db
|
||||
$this->customer_id = new object_property($this->table, $this->id, 'customer_id', 'int', true);
|
||||
$this->type = new object_property($this->table, $this->id, 'type', 'int', true);
|
||||
$this->reg = new object_property($this->table, $this->id, 'reg', 'string', true);
|
||||
$this->reference = new object_property($this->table, $this->id, 'reference', 'string', false);
|
||||
$this->wash_subscription = new object_property($this->table, $this->id, 'wash_subscription', 'bool', false);
|
||||
$this->deleted_at = new object_property($this->table, $this->id, 'deleted_at', 'timestamp', false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user