| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace App\Module\Pet\Models;
- use UCore\ModelCore;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * 宠物技能使用日志模型
- *
- * field start
- * @property int $id
- * @property int $pet_id
- * @property int $skill_id
- * @property \Carbon\Carbon $used_at
- * @property array $effect_result 技能使用结果
- * @property \Carbon\Carbon $created_at
- * @property \Carbon\Carbon $updated_at
- * field end
- */
- class PetSkillLog extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'pet_skill_logs';
- /**
- * 指示模型是否应该被打上时间戳
- * 由于这是日志表,只需要创建时间,不需要更新时间
- *
- * @var bool
- */
- public $timestamps = true;
- /**
- * 更新时间戳字段名
- * 设置为null表示不使用updated_at字段
- *
- * @var string|null
- */
- const UPDATED_AT = null;
- // attrlist start
- protected $fillable = [
- 'id',
- 'pet_id',
- 'skill_id',
- 'used_at',
- 'effect_result',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'pet_id' => 'integer',
- 'skill_id' => 'integer',
- 'used_at' => 'datetime',
- 'created_at' => 'datetime',
- 'effect_result' => 'json',
- ];
- /**
- * 获取关联的宠物
- *
- * @return BelongsTo
- */
- public function pet(): BelongsTo
- {
- return $this->belongsTo(PetUser::class, 'pet_id');
- }
- /**
- * 获取关联的技能
- *
- * @return BelongsTo
- */
- public function skill(): BelongsTo
- {
- return $this->belongsTo(PetSkill::class, 'skill_id');
- }
- }
|