diff --git a/app/Enums/Mail/SmtpOption.php b/app/Enums/Mail/SmtpOption.php index f252f658..6fbeb16f 100644 --- a/app/Enums/Mail/SmtpOption.php +++ b/app/Enums/Mail/SmtpOption.php @@ -23,4 +23,10 @@ final class SmtpOption /** @var string 超时时间 */ const Timeout = 'timeout'; + + /** @var string 发件人地址 */ + const FromAddress = 'from_address'; + + /** @var string 发件人名称 */ + const FromName = 'from_name'; } diff --git a/app/Http/Controllers/Admin/SettingController.php b/app/Http/Controllers/Admin/SettingController.php index 62ff2486..a7cf2746 100644 --- a/app/Http/Controllers/Admin/SettingController.php +++ b/app/Http/Controllers/Admin/SettingController.php @@ -3,18 +3,27 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Models\Config; +use App\Utils; +use Illuminate\Http\Request; use Illuminate\Http\Response; +use Illuminate\Support\Facades\Cache; use Illuminate\View\View; class SettingController extends Controller { public function index(): View { - return view('admin.setting.index'); + $configs = Utils::config(); + return view('admin.setting.index', compact('configs')); } - public function save(): Response + public function save(Request $request): Response { + foreach ($request->all() as $key => $value) { + Config::query()->where('name', $key)->update(['value' => $value]); + } + Cache::flush(); return $this->success('保存成功'); } } diff --git a/resources/views/admin/setting/index.blade.php b/resources/views/admin/setting/index.blade.php index 6b6e8c95..5cc9abef 100644 --- a/resources/views/admin/setting/index.blade.php +++ b/resources/views/admin/setting/index.blade.php @@ -7,19 +7,19 @@