- 新增 Preline UI 3.2.3 作為 UI 組件庫 - 更新 tailwind.config.js 整合 Preline - 更新 app.js 初始化 Preline - 完全重寫 README.md 以 Docker 容器化架構為核心 - 新增 Docker 常用指令大全 - 新增故障排除與生產部署指南 - 新增會員系統相關功能(會員、錢包、點數、會籍、禮物) - 新增社交登入測試功能
63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class MembershipTier extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'annual_fee',
|
|
'discount_rate',
|
|
'point_multiplier',
|
|
'description',
|
|
'is_default',
|
|
'sort_order',
|
|
];
|
|
|
|
protected $casts = [
|
|
'annual_fee' => 'decimal:2',
|
|
'discount_rate' => 'decimal:2',
|
|
'point_multiplier' => 'decimal:2',
|
|
'is_default' => 'boolean',
|
|
'sort_order' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 此等級的會員紀錄
|
|
*/
|
|
public function memberships(): HasMany
|
|
{
|
|
return $this->hasMany(MemberMembership::class, 'tier_id');
|
|
}
|
|
|
|
/**
|
|
* 此等級的禮品定義
|
|
*/
|
|
public function giftDefinitions(): HasMany
|
|
{
|
|
return $this->hasMany(GiftDefinition::class, 'tier_id');
|
|
}
|
|
|
|
/**
|
|
* 取得預設等級
|
|
*/
|
|
public static function getDefault(): ?self
|
|
{
|
|
return static::where('is_default', true)->first();
|
|
}
|
|
|
|
/**
|
|
* 是否為免費等級
|
|
*/
|
|
public function getIsFreeAttribute(): bool
|
|
{
|
|
return $this->annual_fee <= 0;
|
|
}
|
|
}
|