All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 1m4s
- [DOCS] 補齊 en, ja, zh_TW 語系檔翻譯並完善驗證錯誤訊息 (validation.php) - [FEAT] 角色權限頁面新增「所屬單位」篩選功能 (僅限系統管理員) - [STYLE] 優化角色列表顯示,將「類型」變更為具體「所屬單位」名稱 - [STYLE] 修正角色頁面工具列佈局,搜尋框置前並修正下拉箭頭顯示 - [REFACTOR] 統一全站刪除確認視窗,導入新版 <x-delete-confirm-modal /> 組件 - [REFACTOR] 優化 PermissionController 查詢效能 (Eager Loading) - [FIX] 修正 RoleSeeder 角色命名與資料庫同步邏輯
107 lines
3.2 KiB
PHP
107 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\BasicSettings;
|
|
|
|
use App\Http\Controllers\Admin\AdminController;
|
|
use App\Models\System\PaymentConfig;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
class PaymentConfigController extends AdminController
|
|
{
|
|
/**
|
|
* 顯示金流配置列表
|
|
*/
|
|
public function index(Request $request): View
|
|
{
|
|
$per_page = $request->input('per_page', 20);
|
|
$configs = PaymentConfig::query()
|
|
->when($request->search, function ($query, $search) {
|
|
$query->where('name', 'like', "%{$search}%")
|
|
->orWhereHas('company', function ($q) use ($search) {
|
|
$q->where('name', 'like', "%{$search}%");
|
|
});
|
|
})
|
|
->with(['company', 'creator'])
|
|
->latest()
|
|
->paginate($per_page)
|
|
->withQueryString();
|
|
|
|
return view('admin.basic-settings.payment-configs.index', [
|
|
'paymentConfigs' => $configs
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 顯示新增頁面
|
|
*/
|
|
public function create(): View
|
|
{
|
|
$companies = \App\Models\System\Company::select('id', 'name')->get();
|
|
return view('admin.basic-settings.payment-configs.create', compact('companies'));
|
|
}
|
|
|
|
/**
|
|
* 儲存金流配置
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$request->validate([
|
|
'name' => 'required|string|max:255',
|
|
'company_id' => 'required|exists:companies,id',
|
|
'settings' => 'required|array',
|
|
]);
|
|
|
|
PaymentConfig::create([
|
|
'name' => $request->name,
|
|
'company_id' => $request->company_id,
|
|
'settings' => $request->settings,
|
|
'creator_id' => auth()->id(),
|
|
'updater_id' => auth()->id(),
|
|
]);
|
|
|
|
return redirect()->route('admin.basic-settings.payment-configs.index')
|
|
->with('success', __('Payment Configuration created successfully.'));
|
|
}
|
|
|
|
/**
|
|
* 顯示編輯頁面
|
|
*/
|
|
public function edit(PaymentConfig $paymentConfig): View
|
|
{
|
|
$companies = \App\Models\System\Company::select('id', 'name')->get();
|
|
return view('admin.basic-settings.payment-configs.edit', compact('paymentConfig', 'companies'));
|
|
}
|
|
|
|
/**
|
|
* 更新金流配置
|
|
*/
|
|
public function update(Request $request, PaymentConfig $paymentConfig): RedirectResponse
|
|
{
|
|
$request->validate([
|
|
'name' => 'required|string|max:255',
|
|
'settings' => 'required|array',
|
|
]);
|
|
|
|
$paymentConfig->update([
|
|
'name' => $request->name,
|
|
'settings' => $request->settings,
|
|
'updater_id' => auth()->id(),
|
|
]);
|
|
|
|
return redirect()->route('admin.basic-settings.payment-configs.index')
|
|
->with('success', __('Payment Configuration updated successfully.'));
|
|
}
|
|
|
|
/**
|
|
* 刪除金流配置
|
|
*/
|
|
public function destroy(PaymentConfig $paymentConfig): RedirectResponse
|
|
{
|
|
$paymentConfig->delete();
|
|
return redirect()->route('admin.basic-settings.payment-configs.index')
|
|
->with('success', __('Payment Configuration deleted successfully.'));
|
|
}
|
|
}
|