| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?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 $user_task_id 用户任务ID,外键关联task_user_tasks表
- * @property array $rewards 奖励内容(JSON格式)
- * @property string $rewarded_at 奖励发放时间
- * @property string $ip_address IP地址
- * @property string $device_info 设备信息
- * @property \Carbon\Carbon $created_at 创建时间
- * field end
- */
- class TaskRewardLog extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'task_reward_logs';
- /**
- * 主键
- *
- * @var string
- */
- protected $primaryKey = 'id';
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'rewards' => 'array',
- ];
- /**
- * 应该被转换为日期的属性
- *
- * @var array
- */
- protected $dates = [
- 'rewarded_at',
- 'created_at',
- ];
- /**
- * 指示模型是否应该被打上时间戳
- *
- * @var bool
- */
- public $timestamps = false;
- // attrlist start
- protected $fillable = [
- 'id',
- 'user_id',
- 'task_id',
- 'user_task_id',
- 'rewards',
- 'rewarded_at',
- 'ip_address',
- 'device_info',
- ];
- // attrlist end
- /**
- * 获取关联的任务
- *
- * @return BelongsTo
- */
- public function task(): BelongsTo
- {
- return $this->belongsTo(Task::class, 'task_id', 'id');
- }
- /**
- * 获取关联的用户任务
- *
- * @return BelongsTo
- */
- public function userTask(): BelongsTo
- {
- return $this->belongsTo(TaskUserTask::class, 'user_task_id', 'id');
- }
- }
|