feat: 統一各模組分頁組件佈局並新增系統設定功能相關檔案
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 1m5s
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 1m5s
This commit is contained in:
46
app/Modules/Core/Controllers/SystemSettingController.php
Normal file
46
app/Modules/Core/Controllers/SystemSettingController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Core\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Modules\Core\Models\SystemSetting;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class SystemSettingController extends Controller
|
||||
{
|
||||
/**
|
||||
* 顯示系統設定頁面
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$settings = SystemSetting::all()->groupBy('group');
|
||||
|
||||
return Inertia::render('Admin/Setting/Index', [
|
||||
'settings' => $settings,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新系統設定
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'settings' => 'required|array',
|
||||
'settings.*.key' => 'required|string|exists:system_settings,key',
|
||||
'settings.*.value' => 'nullable',
|
||||
]);
|
||||
|
||||
foreach ($validated['settings'] as $item) {
|
||||
SystemSetting::where('key', $item['key'])->update([
|
||||
'value' => $item['value']
|
||||
]);
|
||||
}
|
||||
|
||||
// 清除記憶體快取,確保後續讀取拿到最新值
|
||||
SystemSetting::clearCache();
|
||||
|
||||
return redirect()->back()->with('success', '系統設定已更新');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user