diff --git a/pandora_console/include/rest-api/models/Model.php b/pandora_console/include/rest-api/models/Model.php index 28cac4dc2a..2677f5c3ae 100644 --- a/pandora_console/include/rest-api/models/Model.php +++ b/pandora_console/include/rest-api/models/Model.php @@ -59,6 +59,26 @@ abstract class Model abstract static protected function encode(array $data): array; + /** + * Inserts a new item model in the database + * + * @param array $data Unknown input data structure. + * + * @return boolean The modeled element data structure stored into the DB. + * + * @overrides Model::save. + */ + public static function create(array $data=[]): int + { + // Insert. + $save = static::encode($data); + + $result = \db_process_sql_insert('tlayout_data', $save); + + return $result; + } + + /** * Insert or update an item in the database * diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php index 506f4e6100..bbfebf5416 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Item.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php @@ -1801,26 +1801,6 @@ class Item extends CachedModel } - /** - * Inserts a new item in the database - * - * @param array $data Unknown input data structure. - * - * @return boolean The modeled element data structure stored into the DB. - * - * @overrides Model::save. - */ - public static function create(array $data=[]): int - { - // Insert. - $save = static::encode($data); - - $result = \db_process_sql_insert('tlayout_data', $save); - - return $result; - } - - /** * Update an item in the database * diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Line.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Line.php index 832504e515..7aa8a9c401 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Line.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Line.php @@ -230,7 +230,7 @@ final class Line extends Model * * @overrides Model::encode. */ - protected function encode(array $data): array + protected static function encode(array $data): array { $result = []; $result['type'] = LINE_ITEM; @@ -409,8 +409,8 @@ final class Line extends Model } } else { // Update. - $dataModelEncode = $this->encode($this->toArray()); - $dataEncode = $this->encode($data); + $dataModelEncode = static::encode($this->toArray()); + $dataEncode = static::encode($data); $save = array_merge($dataModelEncode, $dataEncode);