php8 vc moved static created method to Model instead Item (for lines)

This commit is contained in:
fbsanchez 2022-01-13 11:43:33 +01:00
parent 59b0b71303
commit a728d384d7
3 changed files with 23 additions and 23 deletions

View File

@ -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
*

View File

@ -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
*

View File

@ -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);