From fecf0efd747e18611e3ebce03c7babf1f362061e Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Thu, 19 Jan 2023 16:23:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E5=AF=B9=E7=AB=AF?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Module.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Models/Module.php b/app/Models/Module.php index 1957e93..6f5eeed 100644 --- a/app/Models/Module.php +++ b/app/Models/Module.php @@ -44,11 +44,17 @@ class Module extends Authenticatable protected static function boot() { parent::boot(); - static::creating(function ($model) { - // if local + static::creating(function (self $model) { if (!app()->environment('local')) { $model->api_token = Str::random(60); } + + // 如果结尾有 / 则去掉 + $model->url = rtrim($model->url, '/'); + }); + static::updating(function (self $model) { + // 如果结尾有 / 则去掉 + $model->url = rtrim($model->url, '/'); }); } @@ -71,7 +77,7 @@ public function remote($func, $requests): array public function http(): PendingRequest { - return Http::module($this->api_token, $this->url)->acceptJson()->timeout(5); + return Http::module($this->api_token, $this->url . '/remote')->acceptJson()->timeout(5); } private function getResponse(Response $response): array