From 3cd6b39d3f6731f3907ec66aed77d36881cce60e Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Mon, 16 Mar 2026 15:10:30 +0700 Subject: [PATCH] refactor: Make content recap type field nullable in the database, migration command, and Filament form. --- app/Console/Commands/MigrateContentRecapCommand.php | 4 ++-- .../Monitoring/ContentRecaps/Schemas/ContentRecapForm.php | 1 - .../2025_12_09_113331_create_content_recaps_table.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/MigrateContentRecapCommand.php b/app/Console/Commands/MigrateContentRecapCommand.php index 45cff24..862ba17 100644 --- a/app/Console/Commands/MigrateContentRecapCommand.php +++ b/app/Console/Commands/MigrateContentRecapCommand.php @@ -105,13 +105,13 @@ public function handle() $this->info('Content recap migration completed successfully!'); } - private function mapContentType(?string $legacyType): int + private function mapContentType(?string $legacyType): ?int { return match (strtolower($legacyType ?? '')) { 'foto' => ContentType::FOTO->value, 'grafis' => ContentType::GRAPHIC->value, 'audio video' => ContentType::VIDEO->value, - default => ContentType::FOTO->value, + default => null, }; } diff --git a/app/Filament/Resources/Monitoring/ContentRecaps/Schemas/ContentRecapForm.php b/app/Filament/Resources/Monitoring/ContentRecaps/Schemas/ContentRecapForm.php index cd85116..a63d02b 100644 --- a/app/Filament/Resources/Monitoring/ContentRecaps/Schemas/ContentRecapForm.php +++ b/app/Filament/Resources/Monitoring/ContentRecaps/Schemas/ContentRecapForm.php @@ -43,7 +43,6 @@ public static function configure(Schema $schema): Schema ->label('Tipe') ->options(ContentType::options()) ->native(false) - ->required() ->in(implode(',', array_column(ContentType::cases(), 'value'))), Select::make('channel') diff --git a/database/migrations/2025_12_09_113331_create_content_recaps_table.php b/database/migrations/2025_12_09_113331_create_content_recaps_table.php index a163a50..7497d22 100644 --- a/database/migrations/2025_12_09_113331_create_content_recaps_table.php +++ b/database/migrations/2025_12_09_113331_create_content_recaps_table.php @@ -20,7 +20,7 @@ public function up(): void $table->text('title'); $table->text('link')->nullable(); $table->date('posting_date')->index(); - $table->enum('type', ContentType::values())->default(ContentType::FOTO->value)->comment(ContentType::comment())->index(); + $table->enum('type', ContentType::values())->nullable()->default(ContentType::FOTO->value)->comment(ContentType::comment())->index(); $table->enum('channel', Channel::values())->default(Channel::WEBSITE->value)->comment(Channel::comment())->index(); $table->enum('social_media', SocialMedia::values())->default(SocialMedia::DISKOMINFO_PURWAKARTA->value)->comment(SocialMedia::comment())->index(); $table->timestamp('created_at')->useCurrent();