wip
This commit is contained in:
parent
65c9f3d185
commit
02a2db2ff5
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Plugin.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author Edward Yang <yangjin@opencart.cn>
|
||||
* @created 2022-07-01 14:22:15
|
||||
* @modified 2022-07-01 14:22:15
|
||||
*/
|
||||
|
||||
namespace Beike\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Plugin extends Model
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ namespace Beike\Plugin;
|
|||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Beike\Repositories\PluginRepo;
|
||||
use Beike\Repositories\SettingRepo;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
|
||||
|
|
@ -108,7 +109,7 @@ class Plugin implements Arrayable, \ArrayAccess
|
|||
|
||||
public function getInstalled(): bool
|
||||
{
|
||||
return true;
|
||||
return PluginRepo::installed($this->code);
|
||||
}
|
||||
|
||||
public function getEnabled(): bool
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* PluginRepo.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author Edward Yang <yangjin@opencart.cn>
|
||||
* @created 2022-07-01 14:23:41
|
||||
* @modified 2022-07-01 14:23:41
|
||||
*/
|
||||
|
||||
namespace Beike\Repositories;
|
||||
|
||||
use Beike\Models\Plugin;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class PluginRepo
|
||||
{
|
||||
public static $installedPlugins;
|
||||
|
||||
/**
|
||||
* 判断插件是否安装
|
||||
*
|
||||
* @param $code
|
||||
* @return bool
|
||||
*/
|
||||
public static function installed($code): bool
|
||||
{
|
||||
$plugins = self::listByCode();
|
||||
return $plugins->has($code);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有已安装插件
|
||||
* @return Plugin[]|Collection
|
||||
*/
|
||||
public static function listByCode()
|
||||
{
|
||||
if (self::$installedPlugins !== null) {
|
||||
return self::$installedPlugins;
|
||||
}
|
||||
return self::$installedPlugins = Plugin::all()->keyBy('code');
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class Order extends Migration
|
||||
class CreatePlugins extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -13,7 +13,12 @@ class Order extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
Schema::create('plugins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('type')->comment('类型: shipping, payment');
|
||||
$table->string('code')->comment('唯一标识');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -23,6 +28,6 @@ class Order extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
Schema::dropIfExists('plugins');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue