generated from panliang/owl-admin-starter
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use Slowlyo\OwlAdmin\Renderers\Tab;
|
|
use Slowlyo\OwlAdmin\Renderers\Tabs;
|
|
|
|
class SettingController extends AdminController
|
|
{
|
|
public function index()
|
|
{
|
|
$page = $this->basePage()->body([
|
|
$this->form(),
|
|
]);
|
|
|
|
return $this->response()->success($page);
|
|
}
|
|
|
|
public function form()
|
|
{
|
|
return $this->baseForm()
|
|
->redirect('')
|
|
->title('')
|
|
->onEvent('')
|
|
->api($this->getStorePath())
|
|
->data(settings()->all())
|
|
->body(Tabs::make()->tabs([
|
|
Tab::make()->title(__('setting.web'))->body([
|
|
amisMake()->TextControl()->name('web_title')->label(__('setting.web_title')),
|
|
amisMake()->ImageControl()
|
|
->receiver($this->uploadImagePath().'?full-url=1')
|
|
->autoUpload(true)
|
|
->name('web_logo')
|
|
->label(__('setting.web_logo')),
|
|
]),
|
|
]));
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$data = $request->except(['items']);
|
|
// 将 null 变为 ""
|
|
foreach ($data as $key => $value) {
|
|
if (is_null($value)) {
|
|
$data[$key] = '';
|
|
}
|
|
}
|
|
|
|
return settings()->adminSetMany($data);
|
|
}
|
|
}
|