[FEAT] 金流配置優化:公司名稱改為選填並優化列表顯示
1. 新增資料庫遷移腳本,將 payment_configs 資料表的 company_id 欄位改為可為空 (nullable)。 2. 修改 PaymentConfigController 的驗證邏輯,允許 company_id 為空值。 3. 調整金流配置的新增與編輯頁面,移除公司名稱的必填限制及相關 JavaScript 攔截邏輯。 4. 優化金流配置列表,當配置未綁定公司時,將顯示標籤改為「系統」。
This commit is contained in:
parent
2f550839cc
commit
450e6dbe67
@ -49,7 +49,7 @@ class PaymentConfigController extends AdminController
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'company_id' => 'required|exists:companies,id',
|
||||
'company_id' => 'nullable|exists:companies,id',
|
||||
'settings' => 'required|array',
|
||||
]);
|
||||
|
||||
@ -81,7 +81,7 @@ class PaymentConfigController extends AdminController
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'company_id' => 'required|exists:companies,id',
|
||||
'company_id' => 'nullable|exists:companies,id',
|
||||
'settings' => 'required|array',
|
||||
]);
|
||||
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('payment_configs', function (Blueprint $table) {
|
||||
$table->foreignId('company_id')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('payment_configs', function (Blueprint $table) {
|
||||
$table->foreignId('company_id')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -30,12 +30,6 @@
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (!this.$el.company_id.value.trim()) {
|
||||
window.dispatchEvent(new CustomEvent('toast', {
|
||||
detail: { message: '{{ __("Please select a company") }}', type: 'error' }
|
||||
}));
|
||||
return;
|
||||
}
|
||||
this.$el.submit();
|
||||
}
|
||||
}"
|
||||
@ -72,10 +66,9 @@
|
||||
<input type="text" name="name" required class="luxury-input w-full" placeholder="{{ __('e.g., Company Standard Pay') }}">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[11px] font-black text-slate-400 uppercase tracking-[0.2em] mb-2">{{ __('Belongs To Company') }} <span class="text-rose-500">*</span></label>
|
||||
<label class="block text-[11px] font-black text-slate-400 uppercase tracking-[0.2em] mb-2">{{ __('Belongs To Company') }}</label>
|
||||
<x-searchable-select
|
||||
name="company_id"
|
||||
required
|
||||
:selected="old('company_id')"
|
||||
:placeholder="__('Select Company')"
|
||||
>
|
||||
|
||||
@ -30,12 +30,6 @@
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (!this.$el.company_id.value.trim()) {
|
||||
window.dispatchEvent(new CustomEvent('toast', {
|
||||
detail: { message: '{{ __("Please select a company") }}', type: 'error' }
|
||||
}));
|
||||
return;
|
||||
}
|
||||
this.$el.submit();
|
||||
}
|
||||
}"
|
||||
@ -73,10 +67,9 @@
|
||||
<input type="text" name="name" value="{{ $paymentConfig->name }}" required class="luxury-input w-full" placeholder="{{ __('e.g., Company Standard Pay') }}">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[11px] font-black text-slate-400 uppercase tracking-[0.2em] mb-2">{{ __('Belongs To Company') }} <span class="text-rose-500">*</span></label>
|
||||
<label class="block text-[11px] font-black text-slate-400 uppercase tracking-[0.2em] mb-2">{{ __('Belongs To Company') }}</label>
|
||||
<x-searchable-select
|
||||
name="company_id"
|
||||
required
|
||||
:selected="old('company_id', $paymentConfig->company_id)"
|
||||
:placeholder="__('Select Company')"
|
||||
>
|
||||
|
||||
@ -140,7 +140,7 @@
|
||||
</td>
|
||||
<td class="px-6 py-6">
|
||||
<span class="px-2.5 py-1 rounded-lg text-xs font-bold border border-sky-100 dark:border-sky-900/30 bg-sky-50 dark:bg-sky-900/20 text-sky-600 dark:text-sky-400 tracking-widest">
|
||||
{{ $config->company->name ?? __('None') }}
|
||||
{{ $config->company->name ?? __('System') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-6">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user