|
@@ -18,38 +18,67 @@ class SettingsController extends Controller
|
|
|
|
|
|
public function index(Content $content)
|
|
|
{
|
|
|
- return $content->title(admin_trans( 'admin.settings'))
|
|
|
- ->body(
|
|
|
-<<<HTML
|
|
|
-<div class="card">{$this->form()->render()}</div>
|
|
|
-HTML
|
|
|
- );
|
|
|
+ $formTab = isset($_GET['tab']) ? $_GET['tab'] : 0;
|
|
|
+ if ($formTab == 0) {
|
|
|
+ return $content->title(admin_trans( 'admin.settings'))
|
|
|
+ ->body($this->form1());
|
|
|
+ } else {
|
|
|
+ return $content->title(admin_trans( 'admin.settings'))
|
|
|
+ ->body($this->form2());
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- protected function form()
|
|
|
+
|
|
|
+ * 域名配置
|
|
|
+ */
|
|
|
+ protected function form1()
|
|
|
{
|
|
|
- $formTab = isset($_GET['tab']) ? $_GET['tab'] : 0;
|
|
|
- $formTab1 = ($formTab == 0);
|
|
|
- $formTab2 = ($formTab != 0);
|
|
|
$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)->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();
|
|
|
- },$formTab1);
|
|
|
- $form->tab('site', function (Form $form) use ($distInfo) {
|
|
|
- $form->setFormId('tab-form-2');
|
|
|
+ $form = new \Dcat\Admin\Form();
|
|
|
+ $form->title(admin_trans_label('domain'));
|
|
|
+
|
|
|
+ $form->action('/dist-settings');
|
|
|
+ $form->hidden('act')->value('domain');
|
|
|
+
|
|
|
+ $secondaryDomain = $distInfo->secondary_domain ? $distInfo->secondary_domain : '';
|
|
|
+ $customDomain = $distInfo->custom_domain ? $distInfo->custom_domain : '';
|
|
|
+ $form->radio('domain_type')
|
|
|
+ ->when(0, function (\Dcat\Admin\Form $form) use ($secondaryDomain) {
|
|
|
+ $form->text('secondary_domain')->width(4,2)->value($secondaryDomain)->readOnly();
|
|
|
+ })
|
|
|
+ ->when(1, function (\Dcat\Admin\Form $form) use ($customDomain){
|
|
|
+ $form->text('custom_domain')->width(4,2)->value($customDomain)->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->disableListButton();
|
|
|
+ $form->disableViewCheck();
|
|
|
+ $form->disableEditingCheck();
|
|
|
+ $form->disableCreatingCheck();
|
|
|
+ return $form;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 站点配置
|
|
|
+ */
|
|
|
+ protected function form2()
|
|
|
+ {
|
|
|
+ $distInfo = DistAdminDistributor::getInfo();
|
|
|
+ $form = new \Dcat\Admin\Form();
|
|
|
+ $form->title(admin_trans_label('site'));
|
|
|
+
|
|
|
+ $form->action('/dist-settings');
|
|
|
+
|
|
|
+ $form->hidden('act')->value('site');
|
|
|
+
|
|
|
+ $form->column(6, function (\Dcat\Admin\Form $form) use ($distInfo) {
|
|
|
+ $form->text('site_name')->value($distInfo->site_name)->required();
|
|
|
+ $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);
|
|
|
$form->image("logo")
|
|
|
->autoUpload()
|
|
|
->uniqueName()
|
|
@@ -57,11 +86,14 @@ HTML
|
|
|
->maxSize(config('distributor.upload.oss_image.max_size'))
|
|
|
->dir(config("distributor.upload.directory.image").'/logo')
|
|
|
->url('/dist-settings/upload')
|
|
|
- ->default($distInfo->logo);
|
|
|
- $form->text('site_name')->value($distInfo->site_name)->required();
|
|
|
- $form->text('company_name')->value($distInfo->company_name)->required();
|
|
|
+ ->default($distInfo->logo)->width(4,2);
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $form->column(6, function (\Dcat\Admin\Form $form) use ($distInfo) {
|
|
|
+ $form->text('company_name')->value($distInfo->company_name);
|
|
|
$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('facebook')->value($distInfo->facebook);
|
|
@@ -70,11 +102,11 @@ HTML
|
|
|
$form->text('linkedin')->value($distInfo->linkedin);
|
|
|
$form->text('tiktok')->value($distInfo->tiktok);
|
|
|
$form->text('copy_right')->value($distInfo->copy_right);
|
|
|
- $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);
|
|
|
- },$formTab2);
|
|
|
-
|
|
|
+ });
|
|
|
+ $form->disableListButton();
|
|
|
+ $form->disableViewCheck();
|
|
|
+ $form->disableEditingCheck();
|
|
|
+ $form->disableCreatingCheck();
|
|
|
return $form;
|
|
|
}
|
|
|
|
|
@@ -84,26 +116,19 @@ HTML
|
|
|
*/
|
|
|
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');
|
|
|
+ $act = $request->input('act');
|
|
|
+ if ($act == 'domain') {
|
|
|
+ $domainType = $request->input('domain_type');
|
|
|
+ $customDomain = $request->input('custom_domain');
|
|
|
+ if (!in_array($domainType, [0,1])) {
|
|
|
+ return $form->response()->error('Invalid argument');
|
|
|
}
|
|
|
- if (!isDomainOnly($customDomain)) {
|
|
|
- return $form->response()->error('Error in domain format');
|
|
|
- }
|
|
|
- }*/
|
|
|
- $customDomain = $this->removeHttpAndPort($customDomain);
|
|
|
- DistAdminDistributor::updateDomain($domainType,$customDomain);
|
|
|
-
|
|
|
-
|
|
|
- DistAdminDistributor::updateInfo($request->all());
|
|
|
-
|
|
|
+ $customDomain = $this->removeHttpAndPort($customDomain);
|
|
|
+ DistAdminDistributor::updateDomain($domainType,$customDomain);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ DistAdminDistributor::updateInfo($request->all());
|
|
|
+ }
|
|
|
return $form->response()->success('Success');
|
|
|
}
|
|
|
|