ItemNodeMission.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Model;
  3. use App\Traits\HasCustomFields;
  4. class ItemNodeMission extends DataScopeBaseModel
  5. {
  6. protected $table = "item_node_mission"; //指定表
  7. const CREATED_AT = 'crt_time';
  8. const UPDATED_AT = 'upd_time';
  9. protected $dateFormat = 'U';
  10. const employee_column = "crt_id";
  11. const table_column = "item_node_mission_employee";
  12. const table_id_column = "item_node_mission_id";
  13. const Order_type = "item_node_mission";
  14. public static $field = ['*'];
  15. const TYPE_MINUS_TWO = -2;
  16. const TYPE_MINUS_ONE = -1;
  17. const TYPE_ONE = 1;
  18. const TYPE_TWO = 2;
  19. const TYPE_THREE = 3;
  20. const State_Type = [
  21. self::TYPE_MINUS_ONE => '审核中',
  22. self::TYPE_MINUS_TWO => '已超期',
  23. self::TYPE_ONE => '待开始',
  24. self::TYPE_TWO => '进行中',
  25. self::TYPE_THREE => '已完成',
  26. ];
  27. const delivery_zero = 0;
  28. const delivery_one = 1;
  29. const Delivery_Attribute = [
  30. self::delivery_zero => '否',
  31. self::delivery_one => '是',
  32. ];
  33. const entrust_zero = 0;
  34. const entrust_one = 1;
  35. const entrust_two = 2;
  36. const Entrust_Attribute = [
  37. self::entrust_zero => '无',
  38. self::entrust_one => '境内委托',
  39. self::entrust_two => '境外委托',
  40. ];
  41. const review_zero = 0;
  42. const review_one = 1;
  43. const Review_Attribute = [
  44. self::review_zero => '否',
  45. self::review_one => '是',
  46. ];
  47. // 引入自定义字段预加载关系
  48. use HasCustomFields;
  49. // 作用域 里面关联了客户自定义的表头数据 列表页需要 :: withCustomData($user) 这个是预加载
  50. public function scopeWithCustomData($query, $user)
  51. {
  52. $top_depart_id = $user['top_depart_id'];
  53. return $query->with(['customFields' => function ($subQuery) use ($top_depart_id) {
  54. $subQuery->where('top_depart_id', $top_depart_id)
  55. ->where('table_name', $this->table)
  56. ->where('del_time', 0);
  57. }]);
  58. }
  59. }