BlueTask.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\model\blue;
  3. use app\extra\basic\Model;
  4. use think\model\relation\HasOne;
  5. /**
  6. * @property integer $id (主键)
  7. * @property integer $category_id
  8. * @property string $title
  9. * @property mixed $banner
  10. * @property integer $need_num 招募名额
  11. * @property integer $user_num 报名人数
  12. * @property integer $sale_price 产品售价
  13. * @property integer $req_user_level
  14. * @property integer $req_dy_level
  15. */
  16. class BlueTask extends Model
  17. {
  18. /**
  19. * The connection name for the model.
  20. *
  21. * @var string|null
  22. */
  23. protected $connection = 'mysql';
  24. /**
  25. * The table associated with the model.
  26. *
  27. * @var string
  28. */
  29. protected string $table = "blue_task";
  30. /**
  31. * The primary key associated with the table.
  32. *
  33. * @var string
  34. */
  35. protected string $primaryKey = "id";
  36. /**
  37. * Indicates if the model should be timestamped.
  38. *
  39. * @var bool
  40. */
  41. public bool $timestamps = false;
  42. public function getTotalBudgetAttr($val): string
  43. {
  44. return format_money($val/100);
  45. }
  46. public function getExpirationTimeEndAttr($val): int
  47. {
  48. return strtotime($val);
  49. }
  50. public function getNeedNumberAttr($val): int
  51. {
  52. return $val>0?$val:999;
  53. }
  54. public function categoryJoin(): HasOne
  55. {
  56. return $this->hasOne(BlueCategory::class,'sign','category');
  57. }
  58. public function levelJoin(): HasOne
  59. {
  60. return $this->hasOne(BlueExpertLevel::class,'id','level');
  61. }
  62. }