From 6b718a3cfac1d0c38e67c3617163f2651a5ff4fa Mon Sep 17 00:00:00 2001 From: igor Date: Thu, 12 Feb 2026 01:18:15 +0100 Subject: [PATCH] generated DB models --- backend/src/Models/DiaryDays.php | 81 +++++++++++++++++++++++++++ backend/src/Models/DiaryEntries.php | 82 +++++++++++++++++++++++++++ backend/src/Models/Ingredients.php | 87 +++++++++++++++++++++++++++++ backend/src/Models/MealItems.php | 82 +++++++++++++++++++++++++++ backend/src/Models/Meals.php | 82 +++++++++++++++++++++++++++ backend/src/Models/Options.php | 80 ++++++++++++++++++++++++++ backend/src/Models/Users.php | 81 +++++++++++++++++++++++++++ 7 files changed, 575 insertions(+) create mode 100644 backend/src/Models/DiaryDays.php create mode 100644 backend/src/Models/DiaryEntries.php create mode 100644 backend/src/Models/Ingredients.php create mode 100644 backend/src/Models/MealItems.php create mode 100644 backend/src/Models/Meals.php create mode 100644 backend/src/Models/Options.php create mode 100644 backend/src/Models/Users.php diff --git a/backend/src/Models/DiaryDays.php b/backend/src/Models/DiaryDays.php new file mode 100644 index 0000000..ab86d7c --- /dev/null +++ b/backend/src/Models/DiaryDays.php @@ -0,0 +1,81 @@ + array( + 'name' => 'diary_days', + 'primary_key_name' => 'diary_day_id', + 'allow_attributes' => array( + 'user_id' => 'bigint(20) unsigned', + 'day_date' => 'date', + 'created_at' => 'datetime' + ) + ), + ); + + public function exist($primary_key = null) { + return $this->existRecord('diaryDays', $primary_key); + } + + public function diaryDay($primary_key = null, $data = array()) { + return $this->record('diaryDays', $primary_key, $data); + } + + public function diaryDayBy($colname, $colvalue) { + return $this->recordBy('diaryDays', $colname, $colvalue); + } + + public function diaryDaySave($data = array()) { + return $this->diaryDay($this->exist($data) ? $data : null, $data); + } + + public function diaryDayEmpty() { + return $this->recordEmpty('diaryDays'); + } + + public function diaryDayAttributes() { + return $this->typesAttributes('diaryDays'); + } + + public function diaryDayCount() { + return $this->count('diaryDays'); + } + + public function getList($search = array(), $reverse = false, $concat_or = false) { + return $this->search('diaryDays') + ->where($search, $concat_or) + ->order(array('diary_day_id' => $reverse ? 'DESC' : 'ASC')) + ->toArray(); + } + + public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) { + $all = $this->getList($search, $reverse, $concat_or); + $ret = array(); + if (is_array($all)) foreach ($all as $key => $row) { + $ret[$row[$cola_name]] = $row; + } + return $ret; + } + + public function getListByID($search = array(), $reverse = false, $concat_or = false) { + return $this->getListOrganize('diary_day_id', $search, $reverse, $concat_or); + } + + public function diaryDayCombo($col_key, $col_value, $add_empty = false) { + return $this->search('diaryDays') + ->toCombo($col_key, $col_value, $add_empty); + } + +} + +?> diff --git a/backend/src/Models/DiaryEntries.php b/backend/src/Models/DiaryEntries.php new file mode 100644 index 0000000..9d6322f --- /dev/null +++ b/backend/src/Models/DiaryEntries.php @@ -0,0 +1,82 @@ + array( + 'name' => 'diary_entries', + 'primary_key_name' => 'diary_entry_id', + 'allow_attributes' => array( + 'diary_day_id' => 'bigint(20) unsigned', + 'meal_type' => 'enum("breakfast","lunch","dinner")', + 'meal_id' => 'bigint(20) unsigned', + 'created_at' => 'datetime' + ) + ), + ); + + public function exist($primary_key = null) { + return $this->existRecord('diaryEntries', $primary_key); + } + + public function diaryEntry($primary_key = null, $data = array()) { + return $this->record('diaryEntries', $primary_key, $data); + } + + public function diaryEntryBy($colname, $colvalue) { + return $this->recordBy('diaryEntries', $colname, $colvalue); + } + + public function diaryEntrySave($data = array()) { + return $this->diaryEntry($this->exist($data) ? $data : null, $data); + } + + public function diaryEntryEmpty() { + return $this->recordEmpty('diaryEntries'); + } + + public function diaryEntryAttributes() { + return $this->typesAttributes('diaryEntries'); + } + + public function diaryEntryCount() { + return $this->count('diaryEntries'); + } + + public function getList($search = array(), $reverse = false, $concat_or = false) { + return $this->search('diaryEntries') + ->where($search, $concat_or) + ->order(array('diary_entry_id' => $reverse ? 'DESC' : 'ASC')) + ->toArray(); + } + + public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) { + $all = $this->getList($search, $reverse, $concat_or); + $ret = array(); + if (is_array($all)) foreach ($all as $key => $row) { + $ret[$row[$cola_name]] = $row; + } + return $ret; + } + + public function getListByID($search = array(), $reverse = false, $concat_or = false) { + return $this->getListOrganize('diary_entry_id', $search, $reverse, $concat_or); + } + + public function diaryEntryCombo($col_key, $col_value, $add_empty = false) { + return $this->search('diaryEntries') + ->toCombo($col_key, $col_value, $add_empty); + } + +} + +?> diff --git a/backend/src/Models/Ingredients.php b/backend/src/Models/Ingredients.php new file mode 100644 index 0000000..cc38dd7 --- /dev/null +++ b/backend/src/Models/Ingredients.php @@ -0,0 +1,87 @@ + array( + 'name' => 'ingredients', + 'primary_key_name' => 'ingredient_id', + 'allow_attributes' => array( + 'user_id' => 'bigint(20) unsigned', + 'name' => 'varchar(255)', + 'protein_g_100' => 'decimal(7,2)', + 'carbs_g_100' => 'decimal(7,2)', + 'sugar_g_100' => 'decimal(7,2)', + 'fat_g_100' => 'decimal(7,2)', + 'fiber_g_100' => 'decimal(7,2)', + 'kcal_100' => 'decimal(8,2)', + 'created_at' => 'datetime' + ) + ), + ); + + public function exist($primary_key = null) { + return $this->existRecord('ingredients', $primary_key); + } + + public function ingredient($primary_key = null, $data = array()) { + return $this->record('ingredients', $primary_key, $data); + } + + public function ingredientBy($colname, $colvalue) { + return $this->recordBy('ingredients', $colname, $colvalue); + } + + public function ingredientSave($data = array()) { + return $this->ingredient($this->exist($data) ? $data : null, $data); + } + + public function ingredientEmpty() { + return $this->recordEmpty('ingredients'); + } + + public function ingredientAttributes() { + return $this->typesAttributes('ingredients'); + } + + public function ingredientCount() { + return $this->count('ingredients'); + } + + public function getList($search = array(), $reverse = false, $concat_or = false) { + return $this->search('ingredients') + ->where($search, $concat_or) + ->order(array('ingredient_id' => $reverse ? 'DESC' : 'ASC')) + ->toArray(); + } + + public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) { + $all = $this->getList($search, $reverse, $concat_or); + $ret = array(); + if (is_array($all)) foreach ($all as $key => $row) { + $ret[$row[$cola_name]] = $row; + } + return $ret; + } + + public function getListByID($search = array(), $reverse = false, $concat_or = false) { + return $this->getListOrganize('ingredient_id', $search, $reverse, $concat_or); + } + + public function ingredientCombo($col_key, $col_value, $add_empty = false) { + return $this->search('ingredients') + ->toCombo($col_key, $col_value, $add_empty); + } + +} + +?> diff --git a/backend/src/Models/MealItems.php b/backend/src/Models/MealItems.php new file mode 100644 index 0000000..abe3e28 --- /dev/null +++ b/backend/src/Models/MealItems.php @@ -0,0 +1,82 @@ + array( + 'name' => 'meal_items', + 'primary_key_name' => 'meal_item_id', + 'allow_attributes' => array( + 'meal_id' => 'bigint(20) unsigned', + 'ingredient_id' => 'bigint(20) unsigned', + 'grams' => 'decimal(10,2)', + 'position' => 'int(10) unsigned' + ) + ), + ); + + public function exist($primary_key = null) { + return $this->existRecord('mealItems', $primary_key); + } + + public function mealItem($primary_key = null, $data = array()) { + return $this->record('mealItems', $primary_key, $data); + } + + public function mealItemBy($colname, $colvalue) { + return $this->recordBy('mealItems', $colname, $colvalue); + } + + public function mealItemSave($data = array()) { + return $this->mealItem($this->exist($data) ? $data : null, $data); + } + + public function mealItemEmpty() { + return $this->recordEmpty('mealItems'); + } + + public function mealItemAttributes() { + return $this->typesAttributes('mealItems'); + } + + public function mealItemCount() { + return $this->count('mealItems'); + } + + public function getList($search = array(), $reverse = false, $concat_or = false) { + return $this->search('mealItems') + ->where($search, $concat_or) + ->order(array('meal_item_id' => $reverse ? 'DESC' : 'ASC')) + ->toArray(); + } + + public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) { + $all = $this->getList($search, $reverse, $concat_or); + $ret = array(); + if (is_array($all)) foreach ($all as $key => $row) { + $ret[$row[$cola_name]] = $row; + } + return $ret; + } + + public function getListByID($search = array(), $reverse = false, $concat_or = false) { + return $this->getListOrganize('meal_item_id', $search, $reverse, $concat_or); + } + + public function mealItemCombo($col_key, $col_value, $add_empty = false) { + return $this->search('mealItems') + ->toCombo($col_key, $col_value, $add_empty); + } + +} + +?> diff --git a/backend/src/Models/Meals.php b/backend/src/Models/Meals.php new file mode 100644 index 0000000..34aaf97 --- /dev/null +++ b/backend/src/Models/Meals.php @@ -0,0 +1,82 @@ + array( + 'name' => 'meals', + 'primary_key_name' => 'meal_id', + 'allow_attributes' => array( + 'user_id' => 'bigint(20) unsigned', + 'name' => 'varchar(255)', + 'meal_type' => 'enum("breakfast","lunch","dinner")', + 'created_at' => 'datetime' + ) + ), + ); + + public function exist($primary_key = null) { + return $this->existRecord('meals', $primary_key); + } + + public function meal($primary_key = null, $data = array()) { + return $this->record('meals', $primary_key, $data); + } + + public function mealBy($colname, $colvalue) { + return $this->recordBy('meals', $colname, $colvalue); + } + + public function mealSave($data = array()) { + return $this->meal($this->exist($data) ? $data : null, $data); + } + + public function mealEmpty() { + return $this->recordEmpty('meals'); + } + + public function mealAttributes() { + return $this->typesAttributes('meals'); + } + + public function mealCount() { + return $this->count('meals'); + } + + public function getList($search = array(), $reverse = false, $concat_or = false) { + return $this->search('meals') + ->where($search, $concat_or) + ->order(array('meal_id' => $reverse ? 'DESC' : 'ASC')) + ->toArray(); + } + + public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) { + $all = $this->getList($search, $reverse, $concat_or); + $ret = array(); + if (is_array($all)) foreach ($all as $key => $row) { + $ret[$row[$cola_name]] = $row; + } + return $ret; + } + + public function getListByID($search = array(), $reverse = false, $concat_or = false) { + return $this->getListOrganize('meal_id', $search, $reverse, $concat_or); + } + + public function mealCombo($col_key, $col_value, $add_empty = false) { + return $this->search('meals') + ->toCombo($col_key, $col_value, $add_empty); + } + +} + +?> diff --git a/backend/src/Models/Options.php b/backend/src/Models/Options.php new file mode 100644 index 0000000..d47757b --- /dev/null +++ b/backend/src/Models/Options.php @@ -0,0 +1,80 @@ + array( + 'name' => 'options', + 'primary_key_name' => 'key', + 'allow_attributes' => array( + 'key' => 'varchar(255)', + 'value' => 'varchar(255)' + ) + ), + ); + + public function exist($primary_key = null) { + return $this->existRecord('options', $primary_key); + } + + public function option($primary_key = null, $data = array()) { + return $this->record('options', $primary_key, $data); + } + + public function optionBy($colname, $colvalue) { + return $this->recordBy('options', $colname, $colvalue); + } + + public function optionSave($data = array()) { + return $this->option($this->exist($data) ? $data : null, $data); + } + + public function optionEmpty() { + return $this->recordEmpty('options'); + } + + public function optionAttributes() { + return $this->typesAttributes('options'); + } + + public function optionCount() { + return $this->count('options'); + } + + public function getList($search = array(), $reverse = false, $concat_or = false) { + return $this->search('options') + ->where($search, $concat_or) + ->order(array('key' => $reverse ? 'DESC' : 'ASC')) + ->toArray(); + } + + public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) { + $all = $this->getList($search, $reverse, $concat_or); + $ret = array(); + if (is_array($all)) foreach ($all as $key => $row) { + $ret[$row[$cola_name]] = $row; + } + return $ret; + } + + public function getListByID($search = array(), $reverse = false, $concat_or = false) { + return $this->getListOrganize('key', $search, $reverse, $concat_or); + } + + public function optionCombo($col_key, $col_value, $add_empty = false) { + return $this->search('options') + ->toCombo($col_key, $col_value, $add_empty); + } + +} + +?> diff --git a/backend/src/Models/Users.php b/backend/src/Models/Users.php new file mode 100644 index 0000000..7b78441 --- /dev/null +++ b/backend/src/Models/Users.php @@ -0,0 +1,81 @@ + array( + 'name' => 'users', + 'primary_key_name' => 'user_id', + 'allow_attributes' => array( + 'email' => 'varchar(255)', + 'password_hash' => 'varchar(255)', + 'created_at' => 'datetime' + ) + ), + ); + + public function exist($primary_key = null) { + return $this->existRecord('users', $primary_key); + } + + public function user($primary_key = null, $data = array()) { + return $this->record('users', $primary_key, $data); + } + + public function userBy($colname, $colvalue) { + return $this->recordBy('users', $colname, $colvalue); + } + + public function userSave($data = array()) { + return $this->user($this->exist($data) ? $data : null, $data); + } + + public function userEmpty() { + return $this->recordEmpty('users'); + } + + public function userAttributes() { + return $this->typesAttributes('users'); + } + + public function userCount() { + return $this->count('users'); + } + + public function getList($search = array(), $reverse = false, $concat_or = false) { + return $this->search('users') + ->where($search, $concat_or) + ->order(array('user_id' => $reverse ? 'DESC' : 'ASC')) + ->toArray(); + } + + public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) { + $all = $this->getList($search, $reverse, $concat_or); + $ret = array(); + if (is_array($all)) foreach ($all as $key => $row) { + $ret[$row[$cola_name]] = $row; + } + return $ret; + } + + public function getListByID($search = array(), $reverse = false, $concat_or = false) { + return $this->getListOrganize('user_id', $search, $reverse, $concat_or); + } + + public function userCombo($col_key, $col_value, $add_empty = false) { + return $this->search('users') + ->toCombo($col_key, $col_value, $add_empty); + } + +} + +?>