ItemNode.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Model;
  3. use App\Traits\HasCustomFields;
  4. class ItemNode extends DataScopeBaseModel
  5. {
  6. protected $table = "item_node"; //指定表
  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_employee";
  12. const table_id_column = "item_node_id";
  13. const Order_type = "item_node";
  14. public static $field = ['*'];
  15. const TYPE_ZERO = 0;
  16. const TYPE_ONE = 1;
  17. const TYPE_TWO = 2;
  18. const TYPE_MINUS = -1;
  19. const State_Type = [
  20. self::TYPE_MINUS => '审核驳回',
  21. self::TYPE_ZERO => '未审核',
  22. self::TYPE_ONE => '待审核',
  23. self::TYPE_TWO => '审核通过',
  24. ];
  25. const delivery_zero = 0;
  26. const delivery_one = 1;
  27. const Delivery_Attribute = [
  28. self::delivery_zero => '否',
  29. self::delivery_one => '是',
  30. ];
  31. const entrust_zero = 0;
  32. const entrust_one = 1;
  33. const entrust_two = 2;
  34. const Entrust_Attribute = [
  35. self::entrust_zero => '无',
  36. self::entrust_one => '境内委托',
  37. self::entrust_two => '境外委托',
  38. ];
  39. const review_zero = 0;
  40. const review_one = 1;
  41. const Review_Attribute = [
  42. self::review_zero => '否',
  43. self::review_one => '是',
  44. ];
  45. // 引入自定义字段预加载关系
  46. use HasCustomFields;
  47. // 作用域 里面关联了客户自定义的表头数据 列表页需要 :: withCustomData($user) 这个是预加载
  48. public function scopeWithCustomData($query, $user)
  49. {
  50. $top_depart_id = $user['top_depart_id'];
  51. return $query->with(['customFields' => function ($subQuery) use ($top_depart_id) {
  52. $subQuery->where('top_depart_id', $top_depart_id)
  53. ->where('table_name', $this->table)
  54. ->where('del_time', 0);
  55. }]);
  56. }
  57. }