ModifyController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Http\Controllers\Admin\Config\Register;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use App\Models\Config;
  6. class ModifyController 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/register/modify
  17. */
  18. public function index()
  19. {
  20. return view('admin.config.register.modify', []);
  21. }
  22. /**
  23. * 정보 수정시 저장
  24. * @method POST
  25. * @see /admin/config/register/modify
  26. */
  27. public function store(Request $request)
  28. {
  29. $rules = [
  30. 'change_nickname_day' => 'required|numeric|min:0|max:365',
  31. 'change_email_day' => 'required|numeric|min:0|max:365'
  32. ];
  33. $attributes = [
  34. 'change_nickname_day' => '이름',
  35. 'change_email_day' => 'E-mail'
  36. ];
  37. $posts = $this->validate($request, $rules, [], $attributes);
  38. $this->configModel->save($posts, $attributes);
  39. $message = '정보 수정시 정보가 저장되었습니다.';
  40. return redirect()->route('admin.config.register.modify.index')->with('message', $message);
  41. }
  42. }