From 90d72f2851e4ce67a55338e3191f40eaeb34398c Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Fri, 1 Jul 2022 15:26:59 +0800 Subject: [PATCH] fixed methods --- beike/Repositories/PluginRepo.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/beike/Repositories/PluginRepo.php b/beike/Repositories/PluginRepo.php index eebabe10..f1916412 100644 --- a/beike/Repositories/PluginRepo.php +++ b/beike/Repositories/PluginRepo.php @@ -92,27 +92,31 @@ class PluginRepo /** * 获取所有配送方式 */ - public static function getShippingMethods() + public static function getShippingMethods(): array { $allPlugins = self::allPlugins(); return $allPlugins->where('type', 'shipping')->filter(function ($item) { $plugin = (new Manager)->getPlugin($item->code); - $item->plugin = $plugin; + if ($plugin) { + $item->plugin = $plugin->toArray(); + } return $plugin && $plugin->getEnabled(); - }); + })->toArray(); } /** * 获取所有支付方式 */ - public static function getPaymentMethods() + public static function getPaymentMethods(): array { $allPlugins = self::allPlugins(); return $allPlugins->where('type', 'payment')->filter(function ($item) { $plugin = (new Manager)->getPlugin($item->code); - $item->plugin = $plugin; + if ($plugin) { + $item->plugin = $plugin->toArray(); + } return $plugin && $plugin->getEnabled(); - }); + })->toArray(); } }