diff --git a/app/Http/Controllers/Api/ActivityController.php b/app/Http/Controllers/Api/ActivityController.php index 042bc3d..4424063 100644 --- a/app/Http/Controllers/Api/ActivityController.php +++ b/app/Http/Controllers/Api/ActivityController.php @@ -58,7 +58,7 @@ class ActivityController extends Controller 'start_at' => ['nullable', 'date'], 'end_at' => ['nullable', 'date'], 'address' => ['nullable', 'string', 'max:255'], - 'contact_phone' => ['nullable', 'string', 'max:20'], + 'contact_phone' => ['nullable', 'string', 'max:64'], 'lat' => ['nullable', 'numeric'], 'lng' => ['nullable', 'numeric'], 'detail_html' => ['nullable', 'string'], @@ -113,7 +113,7 @@ class ActivityController extends Controller 'start_at' => ['nullable', 'date'], 'end_at' => ['nullable', 'date'], 'address' => ['nullable', 'string', 'max:255'], - 'contact_phone' => ['nullable', 'string', 'max:20'], + 'contact_phone' => ['nullable', 'string', 'max:64'], 'lat' => ['nullable', 'numeric'], 'lng' => ['nullable', 'numeric'], 'detail_html' => ['nullable', 'string'], diff --git a/app/Http/Controllers/Api/VenueController.php b/app/Http/Controllers/Api/VenueController.php index c51fe7a..3fbc0ad 100644 --- a/app/Http/Controllers/Api/VenueController.php +++ b/app/Http/Controllers/Api/VenueController.php @@ -27,14 +27,14 @@ class VenueController extends Controller 'ticket_type' => ['nullable', 'string', 'max:80'], 'appointment_type' => ['nullable', 'string', 'max:40'], 'open_mode' => ['nullable', 'string', 'max:40', Rule::in(['fulltime', 'scheduled', 'appointment'])], - 'open_time' => ['nullable', 'string', 'max:120'], + 'open_time' => ['nullable', 'string', 'max:65535'], 'reservation_notice' => ['nullable', 'string'], 'ticket_content' => ['nullable', 'string'], 'booking_method' => ['nullable', 'string'], 'visit_form' => ['nullable', 'string'], 'consultation_hours' => ['nullable', 'string'], 'address' => ['nullable', 'string', 'max:255'], - 'contact_phone' => ['nullable', 'string', 'max:20'], + 'contact_phone' => ['nullable', 'string', 'max:64'], 'lat' => ['nullable', 'numeric'], 'lng' => ['nullable', 'numeric'], 'cover_image' => ['nullable', 'string', 'max:255'], @@ -139,14 +139,14 @@ class VenueController extends Controller 'ticket_type' => ['nullable', 'string', 'max:80'], 'appointment_type' => ['nullable', 'string', 'max:40'], 'open_mode' => ['nullable', 'string', 'max:40', Rule::in(['fulltime', 'scheduled', 'appointment'])], - 'open_time' => ['nullable', 'string', 'max:120'], + 'open_time' => ['nullable', 'string', 'max:65535'], 'reservation_notice' => ['nullable', 'string'], 'ticket_content' => ['nullable', 'string'], 'booking_method' => ['nullable', 'string'], 'visit_form' => ['nullable', 'string'], 'consultation_hours' => ['nullable', 'string'], 'address' => ['nullable', 'string', 'max:255'], - 'contact_phone' => ['nullable', 'string', 'max:20'], + 'contact_phone' => ['nullable', 'string', 'max:64'], 'lat' => ['nullable', 'numeric'], 'lng' => ['nullable', 'numeric'], 'cover_image' => ['nullable', 'string', 'max:255'], diff --git a/app/Services/VenueImportService.php b/app/Services/VenueImportService.php index a1655f0..46b47d7 100644 --- a/app/Services/VenueImportService.php +++ b/app/Services/VenueImportService.php @@ -300,7 +300,7 @@ class VenueImportService 'ticket_type' => ['nullable', 'string', 'max:80'], 'appointment_type' => ['nullable', 'string', 'max:40'], 'open_mode' => ['nullable', 'string', 'max:40'], - 'open_time' => ['nullable', 'string', 'max:120'], + 'open_time' => ['nullable', 'string', 'max:65535'], 'ticket_content' => ['nullable', 'string'], 'booking_method' => ['nullable', 'string'], 'visit_form' => ['nullable', 'string'], @@ -308,7 +308,7 @@ class VenueImportService 'detail_html' => ['nullable', 'string'], 'reservation_notice' => ['nullable', 'string'], 'address' => ['nullable', 'string', 'max:255'], - 'contact_phone' => ['nullable', 'string', 'max:20'], + 'contact_phone' => ['nullable', 'string', 'max:64'], 'lat' => ['nullable', 'numeric'], 'lng' => ['nullable', 'numeric'], 'sort' => ['nullable', 'integer', 'min:0'], diff --git a/database/migrations/2026_04_21_120000_widen_contact_phone_on_venues_and_activities.php b/database/migrations/2026_04_21_120000_widen_contact_phone_on_venues_and_activities.php new file mode 100644 index 0000000..2379418 --- /dev/null +++ b/database/migrations/2026_04_21_120000_widen_contact_phone_on_venues_and_activities.php @@ -0,0 +1,54 @@ +getDriverName(); + + if ($driver === 'mysql') { + DB::statement('ALTER TABLE `venues` MODIFY `contact_phone` VARCHAR(64) NULL'); + DB::statement('ALTER TABLE `activities` MODIFY `contact_phone` VARCHAR(64) NULL'); + + return; + } + + if ($driver === 'pgsql') { + DB::statement('ALTER TABLE venues ALTER COLUMN contact_phone TYPE VARCHAR(64)'); + DB::statement('ALTER TABLE activities ALTER COLUMN contact_phone TYPE VARCHAR(64)'); + + return; + } + + // sqlite 等对长度约束较宽松,列已存在时可不改;新环境仍以迁移定义为准 + } + + public function down(): void + { + if (! Schema::hasColumn('venues', 'contact_phone') || ! Schema::hasColumn('activities', 'contact_phone')) { + return; + } + + $driver = Schema::getConnection()->getDriverName(); + + if ($driver === 'mysql') { + DB::statement('ALTER TABLE `venues` MODIFY `contact_phone` VARCHAR(20) NULL'); + DB::statement('ALTER TABLE `activities` MODIFY `contact_phone` VARCHAR(20) NULL'); + + return; + } + + if ($driver === 'pgsql') { + DB::statement('ALTER TABLE venues ALTER COLUMN contact_phone TYPE VARCHAR(20)'); + DB::statement('ALTER TABLE activities ALTER COLUMN contact_phone TYPE VARCHAR(20)'); + } + } +}; diff --git a/database/migrations/2026_04_22_120000_widen_venue_open_time_to_text.php b/database/migrations/2026_04_22_120000_widen_venue_open_time_to_text.php new file mode 100644 index 0000000..65f98b0 --- /dev/null +++ b/database/migrations/2026_04_22_120000_widen_venue_open_time_to_text.php @@ -0,0 +1,48 @@ +getDriverName(); + + if ($driver === 'mysql') { + DB::statement('ALTER TABLE `venues` MODIFY `open_time` TEXT NULL'); + + return; + } + + if ($driver === 'pgsql') { + DB::statement('ALTER TABLE venues ALTER COLUMN open_time TYPE TEXT'); + + return; + } + } + + public function down(): void + { + if (! Schema::hasColumn('venues', 'open_time')) { + return; + } + + $driver = Schema::getConnection()->getDriverName(); + + if ($driver === 'mysql') { + DB::statement('ALTER TABLE `venues` MODIFY `open_time` VARCHAR(120) NULL'); + + return; + } + + if ($driver === 'pgsql') { + DB::statement('ALTER TABLE venues ALTER COLUMN open_time TYPE VARCHAR(120)'); + } + } +};