GeneralController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Http\Controllers\Admin\Config\Setting;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use App\Models\Config;
  6. class GeneralController extends Controller
  7. {
  8. private Config $configModel;
  9. public function __construct(Config $config)
  10. {
  11. $this->configModel = $config;
  12. }
  13. /**
  14. * 기타
  15. * @method GET
  16. * @see /admin/config/setting/general
  17. */
  18. public function index()
  19. {
  20. return view('admin.config.setting.general', [
  21. 'config' => $this->configModel->getAllMeta()
  22. ]);
  23. }
  24. /**
  25. * 기타 저장
  26. * @method POST
  27. * @see /admin/config/setting/general
  28. */
  29. public function store(Request $request)
  30. {
  31. $rules = [
  32. 'g2a_order_bot_token' => 'nullable|string|max:255',
  33. 'g2a_product_bot_token' => 'nullable|string|max:255',
  34. 'g2a_error_bot_token' => 'nullable|string|max:255',
  35. 'main_bot_token' => 'nullable|string|max:255'
  36. ];
  37. $attributes = [
  38. 'g2a_order_bot_token' => 'G2A Order Bot Token',
  39. 'g2a_product_bot_token' => 'G2A Product Bot Token',
  40. 'g2a_error_bot_token' => 'G2A Error Bot Token',
  41. 'main_bot_token' => 'Main Bot Token'
  42. ];
  43. $posts = $this->validate($request, $rules, [], $attributes);
  44. $this->configModel->save($posts, $attributes);
  45. $message = '기타 정보가 저장되었습니다.';
  46. return redirect()->route('admin.config.setting.general.index')->with('message', $message);
  47. }
  48. }