title(admin_trans( 'admin.settings')) ->body( <<{$this->form()->render()} HTML ); } protected function form() { $distInfo = DistAdminDistributor::getInfo(); $form = new Form(); $form->tab('domain', function (Form $form) use ($distInfo) { //查分销商信息 $secondaryDomain = $distInfo->secondary_domain ? $distInfo->secondary_domain : ''; $customDomain = $distInfo->custom_domain ? $distInfo->custom_domain : ''; $form->radio('domain_type') ->when(0, function (Form $form) use ($secondaryDomain) { $form->text('secondary_domain')->width(4,2)->value($secondaryDomain)->readOnly(); }) ->when(1, function (Form $form) use ($customDomain){ $form->text('custom_domain')->width(4,2)->value($customDomain)->required()->help('Please enter the domain name, such as www.example.com,and bind the domain name to the IP address '.env('DIST_SITE_IP')); }) ->options([0=>admin_trans_field('secondary_domain'),1=>admin_trans_field('custom_domain')]) ->value($distInfo->domain_type) ->required(); }); $form->tab('site', function (Form $form) use ($distInfo) { $form->text('site_name')->value($distInfo->site_name)->required(); $form->text('company_name')->value($distInfo->company_name)->required(); $form->text('company_address')->value($distInfo->company_address); $form->text('contact_number')->value($distInfo->contact_number); $form->text('service_hotline')->value($distInfo->service_hotline); $form->text('whats_app')->value($distInfo->whats_app); $form->text('seo_title')->value($distInfo->seo_title)->required(); $form->text('seo_keywords')->value($distInfo->seo_keywords); $form->textarea('seo_description')->value($distInfo->seo_description); }); return $form; } /* * 保存配置 */ public function store(Request $request) { $form = new Form(); $domainType = $request->input('domain_type'); $customDomain = $request->input('custom_domain'); if (!in_array($domainType, [0,1])) { return $form->response()->error('Invalid argument'); } if ($domainType == 1) { if (str_starts_with($customDomain,env('TOP_DOMAIN'))) { return $form->response()->error('Error in domain format'); } if (!isDomainOnly($customDomain)) { return $form->response()->error('Error in domain format'); } } DistAdminDistributor::updateDomain($domainType,$customDomain); //站点配置 DistAdminDistributor::updateInfo($request->all()); return $form->response()->success('Success'); } }