CutterTask.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\model\cutter;
  3. use app\extra\basic\Model;
  4. use app\model\kefu\Kefu;
  5. use app\model\user\UserLevel;
  6. use think\model\relation\HasMany;
  7. use think\model\relation\HasOne;
  8. /**
  9. * 任务
  10. */
  11. class CutterTask extends Model
  12. {
  13. /**
  14. * The connection name for the model.
  15. *
  16. * @var string|null
  17. */
  18. protected $connection = 'mysql';
  19. /**
  20. * The table associated with the model.
  21. *
  22. * @var string
  23. */
  24. protected string $table = "cutter_task";
  25. /**
  26. * The primary key associated with the table.
  27. *
  28. * @var string
  29. */
  30. protected string $primaryKey = "id";
  31. /**
  32. * Indicates if the model should be timestamped.
  33. *
  34. * @var bool
  35. */
  36. public bool $timestamps = false;
  37. public function kefu(): HasOne
  38. {
  39. return $this->hasOne(Kefu::class,"id","kefu_id")->where('is_del',0);
  40. }
  41. public function orderCount(): HasMany
  42. {
  43. return $this->hasMany(CutterOrder::class,"task_id","id");
  44. }
  45. public function UserOrder(): HasOne
  46. {
  47. return $this->hasOne(CutterOrder::class,"task_id","id");
  48. }
  49. public function grade(): HasOne
  50. {
  51. return $this->hasOne(UserLevel::class,"grade","grade");
  52. }
  53. public function label(): HasOne
  54. {
  55. return $this->hasOne(CutterLabel::class,"id","label_id");
  56. }
  57. }