| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace App\Module\Team\Models;
- use App\Module\Team\Enums\TALENT_LEVEL;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- use UCore\ModelCore;
- /**
- * 达人等级配置
- *
- * field start
- * @property int $id 主键ID
- * @property \App\Module\Team\Enums\TALENT_LEVEL $level 等级
- * @property string $name 等级名称
- * @property int $direct_count_required 所需直推人数
- * @property int $team_count_required 所需团队总人数
- * @property float $profit_rate 间推分成比例
- * @property array $benefits 等级权益
- * @property string $icon 等级图标
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class TeamTalentConfig extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'team_talent_configs';
- // attrlist start
- protected $fillable = [
- 'id',
- 'level',
- 'name',
- 'direct_count_required',
- 'team_count_required',
- 'profit_rate',
- 'benefits',
- 'icon',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'level' => TALENT_LEVEL::class,
- 'profit_rate' => 'float',
- 'benefits' => 'json',
- ];
- /**
- * 获取拥有此等级的用户
- *
- * @return HasMany
- */
- public function users()
- {
- return $this->hasMany(TeamUserTalent::class, 'talent_level', 'level');
- }
- /**
- * 获取等级图标的完整URL
- *
- * @return string|null
- */
- public function getIconUrlAttribute()
- {
- if (empty($this->icon)) {
- return null;
- }
- return asset($this->icon);
- }
- }
|