old-hotel-new/app/Admin/Controllers/SettingController.php

96 lines
3.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace App\Admin\Controllers;
use Illuminate\Http\Request;
use Slowlyo\OwlAdmin\Renderers\Tab;
use Slowlyo\OwlAdmin\Renderers\Tabs;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Models\Keyword;
use App\Admin\Components;
class SettingController extends AdminController
{
protected string $queryPath = 'system/settings';
protected string $pageTitle = '系统设置';
public function index()
{
$page = $this->basePage()->body($this->form());
return $this->response()->success($page);
}
public function form()
{
return $this->baseForm()
->redirect('')
->api($this->getStorePath())
->data(settings()->all())
->panelClassName('')
->title('')
->body(
Tabs::make()->tabs([
Tab::make()->title('基本设置')->body([
amisMake()->NumberControl('live_continue_day','续住提醒')->value(0)->size('lg')->description('设置该项提前对应天数在续住列表中显示提醒0天则直到欠费才提醒'),
]),
]),
);
}
public function store(Request $request)
{
$data = $request->only([
'live_continue_day'
]);
return settings()->adminSetMany($data);
}
public function settingFeeConfig(Request $request){
$tabs = $formData = [];
$feeKey = Keyword::where('key', 'cost_nope')->first();
foreach ($feeKey->children as $item){
$tabs[] = Tab::make()->title($item->name)->body(array_map(function($iitem) use (&$formData){
$formData[$iitem['key']] = settings()->get($iitem['key']);
return amisMake()->ComboControl($iitem['key'], $iitem['name'])
->items([
amisMake()->RadiosControl('has_time','根据时间设置')->options(['1' =>'无','2'=>'是'])->selectFirst(true)
->description('如果选择按时间设置,则必须要设置每天维度的价格,否则无法计算'),
amisMake()->ComboControl('values', '金额设置')->multiple(true)->items([
amisMake()->InputGroupControl()->label('配置')->body([
amisMake()->SelectControl('lv')->options(Keyword::getByParentKey('nurse_lv')->pluck('name', 'value')),
Components::make()->decimalControl('fee'),
])
])->visibleOn('this.has_time < 2'),
amisMake()->ComboControl('values', '金额设置')->multiple(true)->items([
amisMake()->InputGroupControl()->label('配置')->body([
amisMake()->SelectControl('lv')->options(Keyword::getByParentKey('nurse_lv')->pluck('name', 'value')),
amisMake()->SelectControl('time_type')->options([
'year'=>'每年','month'=>'每月','day'=>'每天',
]),
Components::make()->decimalControl('fee'),
])
])->visibleOn('this.has_time > 1'),
]);
}, $item->children ?->toArray() ?? []));
}
$page = $this->basePage()->body([
amisMake()->Form()->mode('horizontal')
->data($formData)
->api(admin_url('/const-setting'))
->body(
Tabs::make()->tabs($tabs)
)
]);
return $this->response()->success($page);
}
public function settingFeeConfigStore(Request $request)
{
$data = $request->input();
return settings()->adminSetMany($data);
}
}