ConfigController.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Http\Controllers\Admin\User\Dormant;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use App\Models\Config;
  6. class ConfigController 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/user/point
  17. */
  18. public function index()
  19. {
  20. return view('admin.user.dormant.config', []);
  21. }
  22. /**
  23. * 휴면계정 - 환경설정 저장
  24. * @method POST
  25. * @see /admin/user/point
  26. */
  27. public function store(Request $request)
  28. {
  29. $rules = [
  30. 'user_dormant_use' => 'required|numeric|in:0,1',
  31. 'user_auto_withdraw_day' => 'required|numeric|in:3,5,7,14,30',
  32. 'user_withdraw_shop_review_delete' => 'numeric|nullable',
  33. 'user_withdraw_shop_qna_delete' => 'numeric|nullable',
  34. 'user_withdraw_shop_order_delete' => 'numeric|nullable',
  35. 'user_withdraw_board_qna_delete' => 'numeric|nullable',
  36. 'user_withdraw_shop_wish_list_delete' => 'numeric|nullable',
  37. 'user_withdraw_shop_cart_delete' => 'numeric|nullable'
  38. ];
  39. $attributes = [
  40. 'user_dormant_use' => '휴면계정 전환 여부',
  41. 'user_auto_withdraw_day' => '탈퇴 요청회원 자동삭제 기한',
  42. 'user_withdraw_shop_review_delete' => '탈퇴 요청회원 자동삭제 자료 - 구매후기',
  43. 'user_withdraw_shop_qna_delete' => '탈퇴 요청회원 자동삭제 자료 - 상품문의',
  44. 'user_withdraw_shop_order_delete' => '탈퇴 요청회원 자동삭제 자료 - 주문내역',
  45. 'user_withdraw_board_qna_delete' => '탈퇴 요청회원 자동삭제 자료 - 1:1 상담',
  46. 'user_withdraw_shop_wish_list_delete' => '탈퇴 요청회원 자동삭제 자료 - 관심상품',
  47. 'user_withdraw_shop_cart_delete' => '탈퇴 요청회원 자동삭제 자료 - 장바구니'
  48. ];
  49. $posts = $this->validate($request, $rules, [], $attributes);
  50. $posts['user_withdraw_shop_review_delete'] ??= 0;
  51. $posts['user_withdraw_shop_qna_delete'] ??= 0;
  52. $posts['user_withdraw_shop_order_delete'] ??= 0;
  53. $posts['user_withdraw_board_qna_delete'] ??= 0;
  54. $posts['user_withdraw_shop_wish_list_delete'] ??= 0;
  55. $posts['user_withdraw_shop_cart_delete'] ??= 0;
  56. $this->configModel->save($posts, $attributes);
  57. $message = '환경설정이 저장되었습니다.';
  58. return redirect()->route('admin.user.dormant.config.index')->with('message', $message);
  59. }
  60. }