AgentTask.php 947 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class AgentTask extends Model
  5. {
  6. /**
  7. * 数据库连接名
  8. */
  9. protected $connection = 'mysql';
  10. /**
  11. * 与模型关联的表名
  12. */
  13. protected $table = 'webgame.agent_tasks';
  14. /**
  15. * 可批量赋值的属性
  16. */
  17. protected $fillable = [
  18. 'taskid',
  19. 'task_title',
  20. 'required_referrals',
  21. 'reward_amount',
  22. 'status'
  23. ];
  24. /**
  25. * 表明模型是否应该被打上时间戳
  26. *
  27. * @var bool
  28. */
  29. public $timestamps = false;
  30. /**
  31. * 创建查询范围获取活跃的任务
  32. */
  33. public function scopeActive($query)
  34. {
  35. return $query->where('status', 1);
  36. }
  37. /**
  38. * 获取已完成此任务的用户记录
  39. */
  40. public function completions()
  41. {
  42. return $this->hasMany(AgentUserTaskCompletion::class, 'task_id', 'id');
  43. }
  44. }