From 17150cf734dc463efc6e7b8d84fa0dc61d86865c Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Sun, 25 Aug 2024 15:21:30 +0800 Subject: [PATCH] update QueryLogServiceProvider --- README.md | 25 ++++++++++++++++++++++- app/Providers/QueryLogServiceProvider.php | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d56f95..91abbb8 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ 监听sql执行, 打印日志 - `app/Providers/QueryLogServiceProvider.php` -- `bootstrap\providers.php` +- `bootstrap/providers.php` ### 无限级分类 @@ -28,3 +28,26 @@ | parent_id | 上级id | 默认: 0 | | path | 所有上级id | 默认: -, 例如: -1-2-3- | | sort | 排序 | 正序 | + +### 修改组件鉴权 `permission` 方法 + +- `vendor\slowlyo\owl-admin\src\Renderers\BaseRenderer.php` + +```php +public function filteredResults() +{ + $permissionKey = 'owl_permission'; + + // if (key_exists($permissionKey, $this->amisSchema)) { + // if (!admin_user()->can($this->amisSchema[$permissionKey])) { + // return data_get($this->amisSchema, 'owl_permission_replace_value', ''); + // } + // } + + if (key_exists($permissionKey, $this->amisSchema)) { + $this->amisSchema['visible'] = admin_user()->can($this->amisSchema[$permissionKey]); + } + + return \Slowlyo\OwlAdmin\Support\Cores\AdminPipeline::handle(static::class, $this->amisSchema); +} +``` diff --git a/app/Providers/QueryLogServiceProvider.php b/app/Providers/QueryLogServiceProvider.php index fe0454e..497c6ba 100644 --- a/app/Providers/QueryLogServiceProvider.php +++ b/app/Providers/QueryLogServiceProvider.php @@ -61,7 +61,7 @@ class QueryLogServiceProvider extends ServiceProvider $sql = vsprintf($sql, array_map([$query->connection->getPdo(), 'quote'], $bindings)); } - return sprintf('[%s] %s', $this->formatDuration($query->time), $sql); + return sprintf('[%s] [%s] %s', request()->fullUrl(), $this->formatDuration($query->time), $sql); } /**