ConfigController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Http\Controllers\Admin\Sms;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use App\Models\Config;
  6. use App\Models\SmsLib;
  7. class ConfigController extends Controller
  8. {
  9. private Config $configModel;
  10. private SmsLib $smsLib;
  11. private array $smsConfig;
  12. public function __construct(Config $config, SmsLib $smsLib)
  13. {
  14. $this->configModel = $config;
  15. $this->smsLib = $smsLib;
  16. $this->smsConfig = $this->smsLib->info();
  17. }
  18. /**
  19. * 환경 설정
  20. * @method GET
  21. * @see /admin/sms/config
  22. */
  23. public function index()
  24. {
  25. return view('admin.sms.config.index', [
  26. 'icodeRet' => $this->smsConfig
  27. ]);
  28. }
  29. /**
  30. * 환경 설정 저장
  31. * @method POST
  32. * @see /admin/sms/config
  33. */
  34. public function store(Request $request)
  35. {
  36. $rules = [
  37. 'use_sms' => 'numeric|in:0,1',
  38. 'sms_icode_id' => 'string|nullable',
  39. 'sms_icode_pw' => 'string|nullable',
  40. 'sms_icode_call_num' => 'string|nullable',
  41. 'sms_icode_host' => 'string|nullable',
  42. 'sms_icode_port' => 'numeric|nullable',
  43. 'sms_icode_token' => 'string|nullable|max:255'
  44. ];
  45. $attributes = [
  46. 'use_sms' => 'SMS 기능 ',
  47. 'sms_icode_id' => '아이코드 ID',
  48. 'sms_icode_pw' => '아이코드 PW',
  49. 'sms_icode_call_num' => '문자 발송 번호',
  50. 'sms_icode_host' => '서버 IP',
  51. 'sms_icode_port' => '서버 Port',
  52. 'sms_icode_token' => '토큰키 (Token key)'
  53. ];
  54. $posts = $this->validate($request, $rules, [], $attributes);
  55. $this->configModel->save($posts, $attributes);
  56. $message = '환경 설정 정보가 저장되었습니다.';
  57. return redirect()->route('admin.sms.config.index')->with('message', $message);
  58. }
  59. }