ItemNode.php 1.8 KB

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