From cdde6bcb33d0ba9774ba92f1f8fdfad7145fd370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Tue, 26 Jan 2016 21:38:20 +0100 Subject: [PATCH 1/2] FEATURE: regenerated models for updated database structure --- app/Models/ActionLog.php | 2 +- app/Models/ActionLogType.php | 3 ++- app/Models/Content.php | 6 ++--- ...igration.php => ContentHasCustomField.php} | 9 ++++---- app/Models/CustomField.php | 2 +- app/Models/CustomFieldType.php | 2 +- app/Models/ModuleHasCustomField.php | 3 +-- app/Models/PasswordReset.php | 23 ------------------- 8 files changed, 14 insertions(+), 36 deletions(-) rename app/Models/{Migration.php => ContentHasCustomField.php} (57%) delete mode 100644 app/Models/PasswordReset.php diff --git a/app/Models/ActionLog.php b/app/Models/ActionLog.php index 21207b10..8b95d4b6 100644 --- a/app/Models/ActionLog.php +++ b/app/Models/ActionLog.php @@ -15,7 +15,7 @@ class ActionLog extends Model protected $fillable = [ 'type_id', 'user_id', - 'item_id' + 'parameters' ]; protected $guarded = []; diff --git a/app/Models/ActionLogType.php b/app/Models/ActionLogType.php index ced02dc6..420e4d70 100644 --- a/app/Models/ActionLogType.php +++ b/app/Models/ActionLogType.php @@ -13,7 +13,8 @@ class ActionLogType extends Model public $timestamps = false; protected $fillable = [ - 'name' + 'name', + 'value' ]; protected $guarded = []; diff --git a/app/Models/Content.php b/app/Models/Content.php index 098b6983..908ed8e0 100644 --- a/app/Models/Content.php +++ b/app/Models/Content.php @@ -15,15 +15,15 @@ class Content extends Model protected $fillable = [ 'user_id', 'module_handler', + 'published_from', + 'published_to', 'title_photo', 'title', 'url', 'meta_keywords', 'meta_description', - 'module_settings', 'content', - 'published_from', - 'published_to', + 'module_settings', 'status' ]; diff --git a/app/Models/Migration.php b/app/Models/ContentHasCustomField.php similarity index 57% rename from app/Models/Migration.php rename to app/Models/ContentHasCustomField.php index 95af535b..faab0bce 100644 --- a/app/Models/Migration.php +++ b/app/Models/ContentHasCustomField.php @@ -5,16 +5,17 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; /** - * Class Migration + * Class ContentHasCustomField */ -class Migration extends Model +class ContentHasCustomField extends Model { public $timestamps = false; protected $fillable = [ - 'migration', - 'batch' + 'contents_id', + 'custom_field_id', + 'value' ]; protected $guarded = []; diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php index 2ffefec7..4f0554cf 100644 --- a/app/Models/CustomField.php +++ b/app/Models/CustomField.php @@ -13,8 +13,8 @@ class CustomField extends Model public $timestamps = false; protected $fillable = [ - 'handler', 'name', + 'type_id', 'description', 'default_value', 'regexp', diff --git a/app/Models/CustomFieldType.php b/app/Models/CustomFieldType.php index d8d7a5f0..f50bc710 100644 --- a/app/Models/CustomFieldType.php +++ b/app/Models/CustomFieldType.php @@ -14,7 +14,7 @@ class CustomFieldType extends Model protected $fillable = [ 'name', - 'custom_field_id' + 'handler' ]; protected $guarded = []; diff --git a/app/Models/ModuleHasCustomField.php b/app/Models/ModuleHasCustomField.php index 02d6cc60..56b306a6 100644 --- a/app/Models/ModuleHasCustomField.php +++ b/app/Models/ModuleHasCustomField.php @@ -14,8 +14,7 @@ class ModuleHasCustomField extends Model protected $fillable = [ 'module_handler', - 'custom_field_id', - 'value' + 'custom_field_id' ]; protected $guarded = []; diff --git a/app/Models/PasswordReset.php b/app/Models/PasswordReset.php deleted file mode 100644 index 69daebc9..00000000 --- a/app/Models/PasswordReset.php +++ /dev/null @@ -1,23 +0,0 @@ - Date: Tue, 26 Jan 2016 21:54:10 +0100 Subject: [PATCH 2/2] FIX: add autoincrement to all ID fields --- database/schema.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/database/schema.sql b/database/schema.sql index 82e59e64..6b87396d 100644 --- a/database/schema.sql +++ b/database/schema.sql @@ -1,5 +1,5 @@ -- MySQL Script generated by MySQL Workbench --- Út 26. leden 2016, 21:33:51 CET +-- Út 26. leden 2016, 21:53:01 CET -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering @@ -45,7 +45,7 @@ ENGINE = InnoDB; -- Table `files` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `files` ( - `id` INT NOT NULL, + `id` INT NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL COMMENT 'User, who uploaded this file', `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `filename` VARCHAR(128) NOT NULL, @@ -66,7 +66,7 @@ COMMENT = 'Table containing files which were uploaded into system.'; -- Table `contents` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `contents` ( - `id` INT NOT NULL, + `id` INT NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL, `module_handler` VARCHAR(255) NOT NULL, `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -111,7 +111,7 @@ COMMENT = 'Table with all content pages.'; -- Table `content_history` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `content_history` ( - `id` INT NOT NULL, + `id` INT NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL, `content_id` INT NOT NULL, `changed_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -154,7 +154,7 @@ COMMENT = 'Widget type table contains information about all installed widgets. T -- Table `widgets` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `widgets` ( - `id` INT NOT NULL, + `id` INT NOT NULL AUTO_INCREMENT, `widget_type_handler` VARCHAR(255) NOT NULL, `user_id` INT NOT NULL COMMENT 'User ID who created this widget', `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -223,7 +223,7 @@ ENGINE = InnoDB; -- Table `custom_field_types` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `custom_field_types` ( - `id` INT NOT NULL, + `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(64) NOT NULL COMMENT 'Name of custom field. Given as a translation string (e.g. as dir/section.translation)', `handler` VARCHAR(255) NOT NULL COMMENT 'Class for handling this type of custom field', PRIMARY KEY (`id`), @@ -237,7 +237,7 @@ COMMENT = 'List of all custom field types.'; -- Table `custom_fields` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `custom_fields` ( - `id` INT NOT NULL, + `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(128) NOT NULL, `type_id` INT NOT NULL COMMENT 'Foreign key to custom_field_types table', `description` MEDIUMTEXT NULL DEFAULT NULL COMMENT 'Description used for detailed information about meaning of given custom field', @@ -307,7 +307,7 @@ COMMENT = 'Table used for assigning different custom fields to different modules -- Table `action_log_types` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `action_log_types` ( - `id` INT NOT NULL, + `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(128) NOT NULL, `value` VARCHAR(128) NOT NULL COMMENT 'Log content - represented as translation string.', PRIMARY KEY (`id`)) @@ -319,7 +319,7 @@ COMMENT = 'List of all types which can be logged.'; -- Table `action_log` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `action_log` ( - `id` INT NOT NULL, + `id` INT NOT NULL AUTO_INCREMENT, `type_id` INT NOT NULL, `user_id` INT NOT NULL, `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,