| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Module\Pet\Models;
- use UCore\ModelCore;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use Illuminate\Database\Eloquent\Relations\HasMany;
- /**
- * 宠物争霸赛队伍模型
- *
- * field start
- * @property int $id
- * @property int $season_id 赛季ID
- * @property string $name 队伍名称
- * @property int $leader_id 队长用户ID
- * @property int $total_power 队伍总战力
- * @property int $member_count 成员数量
- * @property \Carbon\Carbon $created_at
- * @property \Carbon\Carbon $updated_at
- * field end
- */
- class PetBattleTeam extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'pet_battle_teams';
- // attrlist start
- protected $fillable = [
- 'id',
- 'season_id',
- 'name',
- 'leader_id',
- 'total_power',
- 'member_count',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'season_id' => 'integer',
- 'leader_id' => 'integer',
- 'total_power' => 'integer',
- 'member_count' => 'integer',
- ];
- /**
- * 获取关联的赛季
- *
- * @return BelongsTo
- */
- public function season(): BelongsTo
- {
- return $this->belongsTo(PetBattleSeason::class, 'season_id');
- }
- /**
- * 获取队伍的所有成员
- *
- * @return HasMany
- */
- public function members(): HasMany
- {
- return $this->hasMany(PetBattleTeamMember::class, 'team_id');
- }
- /**
- * 获取队长用户
- *
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function leader()
- {
- return $this->belongsTo(\App\Models\User::class, 'leader_id');
- }
- }
|