Add relay_machine_id property to department_lanes_o object and extend related functionality
- Introduced `relay_machine_id` to `department_lanes_o` for managing Shelly relay associated with machines. - Updated `add` method and database interactions to support the new property. - Included `relay_machine_id` in `asArray` and field initialization logic. - Enhanced `departmentLanesRoute` to handle `relay_machine_id` via API for creation and updates.
This commit is contained in:
@@ -15,6 +15,7 @@ class department_lanes_o extends db
|
||||
public object_property $name; // The lane name
|
||||
public object_property $relay_in_id; // The Shelly relay for the entrance port (if applicable)
|
||||
public object_property $relay_out_id; // The Shelly relay for the exit port (if applicable)
|
||||
public object_property $relay_machine_id; // The Shelly relay for the machine (if applicable)
|
||||
public object_property $created_at;
|
||||
public object_property $updated_at;
|
||||
public object_property $deleted_at;
|
||||
@@ -31,10 +32,11 @@ class department_lanes_o extends db
|
||||
* @param string $name The lane name
|
||||
* @param string|null $relay_in_id The Shelly relay for the entrance port (if applicable)
|
||||
* @param string|null $relay_out_id The Shelly relay for the exit port (if applicable)
|
||||
* @param string|null $relay_machine_id The Shelly relay for the machine (if applicable)
|
||||
* @return department_lanes_o
|
||||
* @throws Exception If the object was not created successfully
|
||||
*/
|
||||
public function add(int $department, string $name, string $relay_in_id = null, string $relay_out_id = null): self
|
||||
public function add(int $department, string $name, string $relay_in_id = null, string $relay_out_id = null, string $relay_machine_id = null): department_lanes_o
|
||||
{
|
||||
global /** @var db $db */
|
||||
$db;
|
||||
@@ -47,12 +49,16 @@ class department_lanes_o extends db
|
||||
if (!is_null($relay_out_id)) {
|
||||
$relay_out_id = $db->escape_string($relay_out_id);
|
||||
}
|
||||
if (!is_null($relay_machine_id)) {
|
||||
$relay_machine_id = $db->escape_string($relay_machine_id);
|
||||
}
|
||||
// Add the object
|
||||
$tmp_id = self::add_object([
|
||||
'department' => $department,
|
||||
'name' => $name,
|
||||
...(!is_null($relay_in_id) ? ['relay_in_id' => $relay_in_id] : []), // If the relay_in_id is null, it will be set to null in the database
|
||||
...(!is_null($relay_out_id) ? ['relay_out_id' => $relay_out_id] : []), // If the relay_out_id is null, it will be set to null in the database
|
||||
...(!is_null($relay_machine_id) ? ['relay_machine_id' => $relay_machine_id] : []), // If the relay_machine_id is null, it will be set to null in the database
|
||||
]);
|
||||
$this->id = $tmp_id;
|
||||
self::getObjectProperties();
|
||||
@@ -66,6 +72,7 @@ class department_lanes_o extends db
|
||||
$this->name = new object_property($this->table, $this->id, 'name', 'string', false);
|
||||
$this->relay_in_id = new object_property($this->table, $this->id, 'relay_in_id', 'string', false);
|
||||
$this->relay_out_id = new object_property($this->table, $this->id, 'relay_out_id', 'string', false);
|
||||
$this->relay_machine_id = new object_property($this->table, $this->id, 'relay_machine_id', 'string', false);
|
||||
$this->created_at = new object_property($this->table, $this->id, 'created_at', 'timestamp', false);
|
||||
$this->updated_at = new object_property($this->table, $this->id, 'updated_at', 'timestamp', false);
|
||||
$this->deleted_at = new object_property($this->table, $this->id, 'deleted_at', 'timestamp', false);
|
||||
@@ -84,6 +91,7 @@ class department_lanes_o extends db
|
||||
'name' => (string)$this->name->value(),
|
||||
'relay_in_id' => (string)$this->relay_in_id->value(),
|
||||
'relay_out_id' => (string)$this->relay_out_id->value(),
|
||||
'relay_machine_id' => (string)$this->relay_machine_id->value(),
|
||||
'created_at' => (string)$this->created_at->value(),
|
||||
'updated_at' => (string)$this->updated_at->value(),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user