From 74f8cdafe9b6c55ac1c943e587b12b2e6f8be4e7 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Wed, 8 Feb 2023 09:13:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8F=92=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=92=8C=E6=8F=8F=E8=BF=B0=E5=A4=9A=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Admin/Http/Resources/PluginResource.php | 13 +++++++++---- beike/Plugin/Plugin.php | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/beike/Admin/Http/Resources/PluginResource.php b/beike/Admin/Http/Resources/PluginResource.php index abc50a4d..4f56e153 100644 --- a/beike/Admin/Http/Resources/PluginResource.php +++ b/beike/Admin/Http/Resources/PluginResource.php @@ -16,13 +16,18 @@ class PluginResource extends JsonResource */ public function toArray($request): array { + $currentLocale = locale(); + + $name = is_array($this->name) ? ($this->name[$currentLocale] ?? '') : (string) $this->name; + $description = is_array($this->description) ? ($this->description[$currentLocale] ?? '') : (string) $this->description; + $data = [ - 'name' => $this->name, + 'code' => $this->code, + 'name' => $name, + 'description' => $description, + 'path' => $this->path, 'version' => $this->version, 'dir_name' => $this->dirName, - 'path' => $this->path, - 'code' => $this->code, - 'description' => $this->description, 'type' => $this->type, 'type_format' => trans('admin/plugin.' . $this->type), 'icon' => plugin_resize($this->code, $this->icon), diff --git a/beike/Plugin/Plugin.php b/beike/Plugin/Plugin.php index 5d0d6d0f..1e362a23 100644 --- a/beike/Plugin/Plugin.php +++ b/beike/Plugin/Plugin.php @@ -66,14 +66,14 @@ class Plugin implements Arrayable, \ArrayAccess return $this; } - public function setName(string $name): self + public function setName(string|array $name): self { $this->name = $name; return $this; } - public function setDescription(string $description): self + public function setDescription(string|array $description): self { $this->description = $description;