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;