diff --git a/app/Console/Commands/AutoClearLog.php b/app/Console/Commands/AutoClearLog.php index c0d6a160..67f934b4 100644 --- a/app/Console/Commands/AutoClearLog.php +++ b/app/Console/Commands/AutoClearLog.php @@ -72,7 +72,7 @@ class AutoClearLog extends Command UserBanedLog::where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-3 month')))->delete(); // 清除用户各节点 / 节点总计的每天流量数据日志 - UserDailyDataFlow::where('node_id', '<>', null) + UserDailyDataFlow::where('node_id', '<>') ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-1 month'))) ->orWhere('created_at', '<=', date('Y-m-d H:i:s', strtotime('-3 month'))) ->delete(); diff --git a/app/Http/Controllers/Admin/CertController.php b/app/Http/Controllers/Admin/CertController.php index ef75cf0b..f2eb98fa 100644 --- a/app/Http/Controllers/Admin/CertController.php +++ b/app/Http/Controllers/Admin/CertController.php @@ -37,7 +37,7 @@ class CertController extends Controller public function store(CertRequest $request) { if ($cert = NodeCertificate::create($request->validated())) { - return redirect(route('admin.node.cert.update', $cert))->with('successMsg', '生成成功'); + return redirect(route('admin.node.cert.edit', $cert))->with('successMsg', '生成成功'); } return redirect()->back()->withInput()->withErrors('生成失败'); diff --git a/app/Http/Requests/Admin/CertRequest.php b/app/Http/Requests/Admin/CertRequest.php index 69abdf9d..35f7b665 100644 --- a/app/Http/Requests/Admin/CertRequest.php +++ b/app/Http/Requests/Admin/CertRequest.php @@ -8,8 +8,13 @@ class CertRequest extends FormRequest { public function rules() { + $unq_domain = ''; + if ($this->method() === 'PUT' || $this->method() === 'PATCH') { + $unq_domain = ','.$this->cert->id; + } + return [ - 'domain' => 'required|string', + 'domain' => 'required|string|unique:node_certificate,domain'.$unq_domain, 'key' => 'string|nullable', 'pem' => 'string|nullable', ]; diff --git a/app/Models/User.php b/app/Models/User.php index 1f2d88b3..a0005b5e 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -53,7 +53,7 @@ class User extends Authenticatable implements JWTSubject 'expired_at' => $this->expired_at, 'ban_time' => $this->ban_time, 'level' => $this->level_name, - 'group' => $this->group->name ?? null, + 'group' => $this->userGroup->name ?? null, 'last_login' => $this->last_login, 'reset_time' => $this->reset_time, 'invite_num' => $this->invite_num, @@ -219,7 +219,7 @@ class User extends Authenticatable implements JWTSubject public function nodes() { if ($this->attributes['user_group_id']) { - $query = $this->group->nodes(); + $query = $this->userGroup->nodes(); } else { $query = Node::query(); } @@ -227,7 +227,7 @@ class User extends Authenticatable implements JWTSubject return $query->whereStatus(1)->where('level', '<=', $this->attributes['level'] ?? 0); } - public function group(): BelongsTo + public function userGroup(): BelongsTo { return $this->belongsTo(UserGroup::class); } diff --git a/resources/views/admin/node/cert/info.blade.php b/resources/views/admin/node/cert/info.blade.php index ab4ebdfa..87762ed1 100644 --- a/resources/views/admin/node/cert/info.blade.php +++ b/resources/views/admin/node/cert/info.blade.php @@ -7,6 +7,9 @@

@isset($cert) 编辑 @else 添加 @endisset域名证书

+
+ 返 回 +
@if (Session::has('successMsg'))