fixed plugin
This commit is contained in:
parent
3c4a2bdeba
commit
81da48f7b2
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace Beike\Admin\Http\Controllers;
|
||||
|
||||
use Beike\Repositories\PluginRepo;
|
||||
use Exception;
|
||||
use Beike\Plugin\Manager;
|
||||
use Illuminate\Http\Request;
|
||||
use Beike\Repositories\PluginRepo;
|
||||
use Beike\Repositories\SettingRepo;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Beike\Admin\Http\Resources\PluginResource;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
namespace Beike\Repositories;
|
||||
|
||||
use Beike\Models\Plugin;
|
||||
use Beike\Plugin\Manager;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class PluginRepo
|
||||
|
|
@ -63,20 +64,55 @@ class PluginRepo
|
|||
*/
|
||||
public static function installed($code): bool
|
||||
{
|
||||
$plugins = self::listByCode();
|
||||
$plugins = self::getPluginsByCode();
|
||||
return $plugins->has($code);
|
||||
}
|
||||
|
||||
|
||||
public static function allPlugins()
|
||||
{
|
||||
if (self::$installedPlugins !== null) {
|
||||
return self::$installedPlugins;
|
||||
}
|
||||
return self::$installedPlugins = Plugin::all();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有已安装插件
|
||||
* @return Plugin[]|Collection
|
||||
*/
|
||||
public static function listByCode()
|
||||
public static function getPluginsByCode()
|
||||
{
|
||||
if (self::$installedPlugins !== null) {
|
||||
return self::$installedPlugins;
|
||||
}
|
||||
return self::$installedPlugins = Plugin::all()->keyBy('code');
|
||||
$allPlugins = self::allPlugins();
|
||||
return $allPlugins->keyBy('code');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有配送方式
|
||||
*/
|
||||
public static function getShippingMethods()
|
||||
{
|
||||
$allPlugins = self::allPlugins();
|
||||
return $allPlugins->where('type', 'shipping')->filter(function ($item) {
|
||||
$plugin = (new Manager)->getPlugin($item->code);
|
||||
$item->plugin = $plugin;
|
||||
return $plugin && $plugin->getEnabled();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有支付方式
|
||||
*/
|
||||
public static function getPaymentMethods()
|
||||
{
|
||||
$allPlugins = self::allPlugins();
|
||||
return $allPlugins->where('type', 'payment')->filter(function ($item) {
|
||||
$plugin = (new Manager)->getPlugin($item->code);
|
||||
$item->plugin = $plugin;
|
||||
return $plugin && $plugin->getEnabled();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,14 +74,4 @@ class SettingRepo
|
|||
}
|
||||
Setting::query()->insert($rows);
|
||||
}
|
||||
|
||||
public static function getShipments()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getPayments()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class CheckoutController extends Controller
|
|||
public function index(Request $request)
|
||||
{
|
||||
$data = CheckoutService::checkoutData();
|
||||
dd($data);
|
||||
return view('checkout', $data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
namespace Beike\Shop\Services;
|
||||
|
||||
use Beike\Repositories\AddressRepo;
|
||||
use Beike\Repositories\PluginRepo;
|
||||
use Beike\Repositories\SettingRepo;
|
||||
use Beike\Repositories\CountryRepo;
|
||||
|
||||
|
|
@ -22,8 +23,8 @@ class CheckoutService
|
|||
$customer = current_customer();
|
||||
|
||||
$addresses = AddressRepo::listByCustomer(current_customer());
|
||||
$shipments = SettingRepo::getShipments();
|
||||
$payments = SettingRepo::getPayments();
|
||||
$shipments = PluginRepo::getShippingMethods();
|
||||
$payments = PluginRepo::getPaymentMethods();
|
||||
|
||||
$cartList = CartService::list($customer, true);
|
||||
$carts = CartService::reloadData($cartList);
|
||||
|
|
|
|||
Loading…
Reference in New Issue