Browse Source

总后台系统设置

develop
李可松 4 years ago
parent
commit
01ef9c234d
  1. 23
      app/Admin/Controllers/SettingController.php
  2. 52
      app/Admin/Forms/Setting.php
  3. 20
      app/Models/AdminSetting.php

23
app/Admin/Controllers/SettingController.php

@ -0,0 +1,23 @@
<?php
namespace App\Admin\Controllers;
use App\Admin\Forms\Setting;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Card;
/**
* 系统设置
* Class SettingController
* @package App\Admin\Controllers
*/
class SettingController extends AdminController
{
public function index(Content $content)
{
return $content
->title('系统设置')
->body(new Card(new Setting()));
}
}

52
app/Admin/Forms/Setting.php

@ -0,0 +1,52 @@
<?php
namespace App\Admin\Forms;
use Dcat\Admin\Widgets\Form;
class Setting extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
// dump($input);
// return $this->response()->error('Your error message.');
admin_setting($input);
return $this->response()->success('保存成功')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->tab('支付小程序配置', function () {
$this->text('payee_appid', '收款小程序APPID')->required();
$this->text('payee_appsecret', '收款小程序APP_SECRET')->required();
$this->text('payee_mchid', '收款小程序MCH_ID')->required();
$this->text('payee_mchkey', '收款小程序MCH_KEY')->required();
})->tab('小程序服务商配置', function () {
$this->text('service_appid', '小程序第三方平台APPID');
$this->text('service_appsecret', '小程序第三方平台APP_SECRET');
$this->text('service_binding_appid', '绑定小程序APPID');
});
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
return admin_setting()->toArray();
}
}

20
app/Models/AdminSetting.php

@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AdminSetting extends Model
{
use HasFactory;
public static function val($slug)
{
if (is_array($slug)) {
return static::query()->whereIn('slug', $slug)->pluck('value')->toArray() ?? [];
} else {
return static::query()->where('slug', $slug)->value('value') ?? null;
}
}
}
Loading…
Cancel
Save