From 2f550839cc6056b07e5d9b6803a5fa3058ffb800 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Fri, 15 May 2026 17:02:59 +0800 Subject: [PATCH] =?UTF-8?q?[FEAT]=20=E5=AE=A2=E6=88=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=AC=84=E4=BD=8D=EF=BC=88=E5=AE=A2=E6=88=B6=E4=BB=A3=E8=99=9F?= =?UTF-8?q?=E3=80=81=E8=B5=B7=E5=A7=8B=E6=97=A5=EF=BC=89=E9=9D=9E=E5=BF=85?= =?UTF-8?q?=E5=A1=AB=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增遷移檔將 companies.code 改為 nullable 並增加長度至 100,解決刪除時字串過長的問題。 2. 修改 CompanyController 驗證邏輯,允許 code 與 start_date 為空。 3. 更新前端公司管理頁面,移除 code 與 start_date 的必填限制與 UI 標記。 --- .../Controllers/Admin/CompanyController.php | 8 +++--- ...mpany_code_nullable_in_companies_table.php | 28 +++++++++++++++++++ .../views/admin/companies/index.blade.php | 8 +++--- 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 database/migrations/2026_05_15_164013_make_company_code_nullable_in_companies_table.php diff --git a/app/Http/Controllers/Admin/CompanyController.php b/app/Http/Controllers/Admin/CompanyController.php index d863b7d..88a21ed 100644 --- a/app/Http/Controllers/Admin/CompanyController.php +++ b/app/Http/Controllers/Admin/CompanyController.php @@ -48,13 +48,13 @@ class CompanyController extends Controller { $validated = $request->validate([ 'name' => 'required|string|max:255', - 'code' => 'required|string|max:50|unique:companies,code', + 'code' => 'nullable|string|max:50|unique:companies,code', 'original_type' => 'required|string|in:buyout,lease', 'tax_id' => 'nullable|string|max:50', 'contact_name' => 'nullable|string|max:255', 'contact_phone' => 'nullable|string|max:50', 'contact_email' => 'nullable|email|max:255', - 'start_date' => 'required|date', + 'start_date' => 'nullable|date', 'end_date' => 'nullable|date', 'warranty_start_date' => 'nullable|date', 'warranty_end_date' => 'nullable|date', @@ -158,13 +158,13 @@ class CompanyController extends Controller { $validated = $request->validate([ 'name' => 'required|string|max:255', - 'code' => 'required|string|max:50|unique:companies,code,' . $company->id, + 'code' => 'nullable|string|max:50|unique:companies,code,' . $company->id, 'current_type' => 'required|string|in:buyout,lease', 'tax_id' => 'nullable|string|max:50', 'contact_name' => 'nullable|string|max:255', 'contact_phone' => 'nullable|string|max:50', 'contact_email' => 'nullable|email|max:255', - 'start_date' => 'required|date', + 'start_date' => 'nullable|date', 'end_date' => 'nullable|date', 'warranty_start_date' => 'nullable|date', 'warranty_end_date' => 'nullable|date', diff --git a/database/migrations/2026_05_15_164013_make_company_code_nullable_in_companies_table.php b/database/migrations/2026_05_15_164013_make_company_code_nullable_in_companies_table.php new file mode 100644 index 0000000..2e5e8ac --- /dev/null +++ b/database/migrations/2026_05_15_164013_make_company_code_nullable_in_companies_table.php @@ -0,0 +1,28 @@ +string('code', 100)->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('companies', function (Blueprint $table) { + $table->string('code', 20)->nullable(false)->change(); + }); + } +}; diff --git a/resources/views/admin/companies/index.blade.php b/resources/views/admin/companies/index.blade.php index 592098b..23c55c6 100644 --- a/resources/views/admin/companies/index.blade.php +++ b/resources/views/admin/companies/index.blade.php @@ -795,8 +795,8 @@
- +
@@ -811,8 +811,8 @@
- +