diff --git a/CHANGELOG.md b/CHANGELOG.md index 6026f3e..36a4570 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Categories are now unique and required, enforced at the database level - Various database indexes were added for common lookup patterns for quick retrieval +- Fixes various database field types and type validation on form submission to better align with the context they are used with - Fixes a bug that didn't show the dropdown chevrons for form-select fields when creating a post - Fixes a Bootstrap deprecation warning - Updates MariaDB from 10.11 to 11.1 diff --git a/src/app/Http/Controllers/PostController.php b/src/app/Http/Controllers/PostController.php index d6ba3c8..989b839 100644 --- a/src/app/Http/Controllers/PostController.php +++ b/src/app/Http/Controllers/PostController.php @@ -166,7 +166,7 @@ public function create(Request $request): RedirectResponse }) ], 'keywords' => 'nullable|string', - 'category_id' => 'nullable|string', + 'category_id' => 'nullable|integer', 'post' => 'required|string', 'banner_image_url' => 'nullable|string', 'published' => 'required|integer', @@ -206,7 +206,7 @@ public function update(Request $request, int $id): RedirectResponse }) ], 'keywords' => 'nullable|string', - 'category_id' => 'nullable|string', + 'category_id' => 'nullable|integer', 'post' => 'required|string', 'banner_image_url' => 'nullable|string', 'published' => 'required|integer', diff --git a/src/database/migrations/2023_09_20_055545_fix_post_field_types.php b/src/database/migrations/2023_09_20_055545_fix_post_field_types.php new file mode 100644 index 0000000..01d78fc --- /dev/null +++ b/src/database/migrations/2023_09_20_055545_fix_post_field_types.php @@ -0,0 +1,32 @@ +integer('category_id')->change(); + $table->string('keywords')->change(); + $table->mediumText('post')->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('posts', function (Blueprint $table) { + $table->string('category_id')->change(); + $table->text('keywords')->change(); + $table->longText('post')->change(); + }); + } +};