| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class AgentTask extends Model
- {
- /**
- * 数据库连接名
- */
- protected $connection = 'mysql';
- /**
- * 与模型关联的表名
- */
- protected $table = 'webgame.agent_tasks';
- /**
- * 可批量赋值的属性
- */
- protected $fillable = [
- 'taskid',
- 'task_title',
- 'required_referrals',
- 'reward_amount',
- 'status'
- ];
- /**
- * 表明模型是否应该被打上时间戳
- *
- * @var bool
- */
- public $timestamps = false;
- /**
- * 创建查询范围获取活跃的任务
- */
- public function scopeActive($query)
- {
- return $query->where('status', 1);
- }
- /**
- * 获取已完成此任务的用户记录
- */
- public function completions()
- {
- return $this->hasMany(AgentUserTaskCompletion::class, 'task_id', 'id');
- }
- }
|