后台设置admin
This commit is contained in:
parent
46eb687519
commit
9869a4b89c
|
|
@ -23,6 +23,7 @@ class AdminServiceProvider extends ServiceProvider
|
|||
public function boot()
|
||||
{
|
||||
$uri = request()->getRequestUri();
|
||||
load_settings();
|
||||
|
||||
$adminName = admin_name();
|
||||
if (!Str::startsWith($uri, "/{$adminName}")) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Beike\Models\AdminUser;
|
||||
use Beike\Models\Customer;
|
||||
use Beike\Models\Setting;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
|
|
@ -26,10 +27,36 @@ function admin_name(): string
|
|||
{
|
||||
if ($envAdminName = env('ADMIN_NAME')) {
|
||||
return Str::snake($envAdminName);
|
||||
} elseif ($settingAdminName = setting('base.admin_name')) {
|
||||
return Str::snake($settingAdminName);
|
||||
}
|
||||
return 'admin';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取后台设置项
|
||||
*/
|
||||
function load_settings()
|
||||
{
|
||||
$settings = Setting::all(['type', 'space', 'name', 'value', 'json'])
|
||||
->groupBy('space');
|
||||
|
||||
$result = [];
|
||||
foreach ($settings as $space => $groupSettings) {
|
||||
$space = $space ?: 'system';
|
||||
foreach ($groupSettings as $groupSetting) {
|
||||
$name = $groupSetting->name;
|
||||
$value = $groupSetting->value;
|
||||
if ($groupSetting->json) {
|
||||
$result[$space][$name] = json_decode($value, true);
|
||||
} else {
|
||||
$result[$space][$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
config(['bk' => $result]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取后台链接
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ class ShopServiceProvider extends ServiceProvider
|
|||
public function boot()
|
||||
{
|
||||
$uri = request()->getRequestUri();
|
||||
|
||||
$this->loadSettings();
|
||||
load_settings();
|
||||
|
||||
if (Str::startsWith($uri, '/admin')) {
|
||||
return;
|
||||
|
|
@ -39,27 +38,6 @@ class ShopServiceProvider extends ServiceProvider
|
|||
]);
|
||||
}
|
||||
|
||||
protected function loadSettings()
|
||||
{
|
||||
$settings = Setting::all(['type', 'space', 'name', 'value', 'json'])
|
||||
->groupBy('space');
|
||||
|
||||
$result = [];
|
||||
foreach ($settings as $space => $groupSettings) {
|
||||
$space = $space ?: 'system';
|
||||
foreach ($groupSettings as $groupSetting) {
|
||||
$name = $groupSetting->name;
|
||||
$value = $groupSetting->value;
|
||||
if ($groupSetting->json) {
|
||||
$result[$space][$name] = json_decode($value, true);
|
||||
} else {
|
||||
$result[$space][$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
config(['bk' => $result]);
|
||||
}
|
||||
|
||||
protected function registerGuard()
|
||||
{
|
||||
Config::set('auth.guards.' . Customer::AUTH_GUARD, [
|
||||
|
|
|
|||
Loading…
Reference in New Issue