| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace App\Module\Task\Models;
- use UCore\ModelCore;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * 用户任务进度模型
- *
- * field start
- * @property int $id 主键
- * @property int $user_id 用户ID
- * @property int $task_id 任务ID,外键关联task_tasks表
- * @property int $achievement_condition_id 达成条件ID,外键关联task_achievement_conditions表
- * @property int $current_value 当前值
- * @property string $last_update_time 最后更新时间
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class TaskUserProgress extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'task_user_progress';
- /**
- * 主键
- *
- * @var string
- */
- protected $primaryKey = 'id';
- /**
- * 应该被转换为日期的属性
- *
- * @var array
- */
- protected $dates = [
- 'last_update_time',
- 'created_at',
- 'updated_at',
- ];
- // attrlist start
- protected $fillable = [
- 'id',
- 'user_id',
- 'task_id',
- 'achievement_condition_id',
- 'current_value',
- 'last_update_time',
- ];
- // attrlist end
- /**
- * 获取关联的任务
- *
- * @return BelongsTo
- */
- public function task(): BelongsTo
- {
- return $this->belongsTo(Task::class, 'task_id', 'id');
- }
- /**
- * 获取关联的达成条件
- *
- * @return BelongsTo
- */
- public function achievementCondition(): BelongsTo
- {
- return $this->belongsTo(TaskAchievementCondition::class, 'achievement_condition_id', 'id');
- }
- /**
- * 获取关联的用户任务
- *
- * @return BelongsTo
- */
- public function userTask(): BelongsTo
- {
- return $this->belongsTo(TaskUserTask::class, 'task_id', 'task_id')
- ->where('user_id', $this->user_id);
- }
- }
|