| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Module\Promotion\Models;
- use App\Module\Promotion\Enums\TALENT_LEVEL;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- use UCore\ModelCore;
- /**
- * 达人等级配置
- *
- * field start
- * field end
- */
- class PromotionTalentConfig extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'promotion_talent_configs';
- // attrlist start
- protected $fillable = [
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'level' => TALENT_LEVEL::class,
- 'profit_rate' => 'float',
- 'benefits' => 'json',
- ];
- /**
- * 获取拥有此等级的用户
- *
- * @return HasMany
- */
- public function users()
- {
- return $this->hasMany(PromotionUserTalent::class, 'talent_level', 'level');
- }
- /**
- * 获取等级图标的完整URL
- *
- * @return string|null
- */
- public function getIconUrlAttribute()
- {
- if (empty($this->icon)) {
- return null;
- }
- return asset($this->icon);
- }
- }
|