mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 11:20:53 +08:00
feat: enhance plugin management
- Add command support for plugin management - Optimize plugin management page layout - Add email copy functionality for users - Convert payment methods and Telegram Bot to plugin system
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@@ -16,11 +18,27 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string $license
|
||||
* @property string $requires
|
||||
* @property string $config
|
||||
* @property string $type
|
||||
*/
|
||||
class Plugin extends Model
|
||||
{
|
||||
protected $table = 'v2_plugins';
|
||||
|
||||
const TYPE_FEATURE = 'feature';
|
||||
const TYPE_PAYMENT = 'payment';
|
||||
|
||||
// 默认不可删除的插件列表
|
||||
const PROTECTED_PLUGINS = [
|
||||
'epay', // EPay
|
||||
'alipay_f2f', // Alipay F2F
|
||||
'btcpay', // BTCPay
|
||||
'coinbase', // Coinbase
|
||||
'coin_payments', // CoinPayments
|
||||
'mgate', // MGate
|
||||
'smogate', // Smogate
|
||||
'telegram', // Telegram
|
||||
];
|
||||
|
||||
protected $guarded = [
|
||||
'id',
|
||||
'created_at',
|
||||
@@ -28,6 +46,32 @@ class Plugin extends Model
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_enabled' => 'boolean'
|
||||
'is_enabled' => 'boolean',
|
||||
];
|
||||
|
||||
public function scopeByType(Builder $query, string $type): Builder
|
||||
{
|
||||
return $query->where('type', $type);
|
||||
}
|
||||
|
||||
public function isFeaturePlugin(): bool
|
||||
{
|
||||
return $this->type === self::TYPE_FEATURE;
|
||||
}
|
||||
|
||||
public function isPaymentPlugin(): bool
|
||||
{
|
||||
return $this->type === self::TYPE_PAYMENT;
|
||||
}
|
||||
|
||||
public function isProtected(): bool
|
||||
{
|
||||
return in_array($this->code, self::PROTECTED_PLUGINS);
|
||||
}
|
||||
|
||||
public function canBeDeleted(): bool
|
||||
{
|
||||
return !$this->isProtected();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user