CompanyController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. use App\Http\Traits\TossTrait;
  7. class CompanyController extends Controller
  8. {
  9. use TossTrait;
  10. private Config $configModel;
  11. private array $tossBanks;
  12. public function __construct(Config $config)
  13. {
  14. $this->configModel = $config;
  15. $this->tossBanks = $this->getBanks();
  16. }
  17. /**
  18. * 회사
  19. * @method GET
  20. * @see /admin/config/setting/company
  21. */
  22. public function index()
  23. {
  24. return view('admin.config.setting.company', [
  25. 'config' => $this->configModel->getAllMeta(),
  26. 'banks' => $this->tossBanks
  27. ]);
  28. }
  29. /**
  30. * 회사 저장
  31. * @method POST
  32. * @see /admin/config/setting/company
  33. */
  34. public function store(Request $request)
  35. {
  36. $rules = [
  37. 'company_name' => 'string|nullable',
  38. 'company_reg_no' => 'string|nullable',
  39. 'company_owner' => 'string|nullable',
  40. 'company_phone' => 'string|nullable',
  41. 'company_fax' => 'string|nullable',
  42. 'company_retail_sale_no' => 'string|nullable',
  43. 'company_added_sale_no' => 'string|nullable',
  44. 'company_zip_code' => 'string|nullable',
  45. 'company_address' => 'string|nullable',
  46. 'company_hosting' => 'string|nullable',
  47. 'company_admin_name' => 'string|nullable',
  48. 'company_admin_email' => 'string|nullable',
  49. 'company_site_url' => 'string|nullable',
  50. 'company_bank_code' => 'numeric|nullable',
  51. 'company_bank_owner' => 'string|nullable|max:20',
  52. 'company_bank_number' => 'string|nullable|max:20'
  53. ];
  54. $attributes = [
  55. 'company_name' => '회사명',
  56. 'company_reg_no' => '사업자등록번호',
  57. 'company_owner' => '대표자명',
  58. 'company_phone' => '대표전화번호',
  59. 'company_fax' => 'FAX 번호',
  60. 'company_retail_sale_no' => '통신판매업신고번호',
  61. 'company_added_sale_no' => '부가통신 사업자번호',
  62. 'company_zip_code' => '사업장 우편번호',
  63. 'company_address' => '사업장 주소',
  64. 'company_hosting' => '호스팅서비스',
  65. 'company_admin_name' => '정보관리책임자명',
  66. 'company_admin_email' => '정보관리책임자 이메일',
  67. 'company_site_url' => '홈페이지 주소',
  68. 'company_bank_code' => '회사 계좌 정보 - 은행 번호',
  69. 'company_bank_name' => '회사 계좌 정보 - 은행명',
  70. 'company_bank_owner' => '회사 계좌 정보 - 예금주',
  71. 'company_bank_number' => '회사 계좌 정보 - 계좌번호'
  72. ];
  73. $posts = $this->validate($request, $rules, [], $attributes);
  74. if ($posts['company_bank_code']) {
  75. $posts['company_bank_name'] = $this->tossBanks[$posts['company_bank_code']];
  76. }
  77. $this->configModel->save($posts, $attributes);
  78. $message = '회사 정보가 저장되었습니다.';
  79. return redirect()->route('admin.config.setting.company.index')->with('message', $message);
  80. }
  81. }