| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Model;
- use App\Traits\HasCustomFields;
- class ItemNode extends DataScopeBaseModel
- {
- protected $table = "item_node"; //指定表
- const CREATED_AT = 'crt_time';
- const UPDATED_AT = 'upd_time';
- protected $dateFormat = 'U';
- const employee_column = "crt_id";
- const table_column = "item_node_employee";
- const table_id_column = "item_node_id";
- const Order_type = "item_node";
- public static $field = ['*'];
- const TYPE_MINUS_TWO = -2;
- const TYPE_MINUS_ONE = -1;
- const TYPE_ONE = 1;
- const TYPE_TWO = 2;
- const TYPE_THREE = 3;
- const State_Type = [
- self::TYPE_MINUS_ONE => '审核中',
- self::TYPE_MINUS_TWO => '已超期',
- self::TYPE_ONE => '待开始',
- self::TYPE_TWO => '进行中',
- self::TYPE_THREE => '已完成',
- ];
- const delivery_zero = 0;
- const delivery_one = 1;
- const Delivery_Attribute = [
- self::delivery_zero => '否',
- self::delivery_one => '是',
- ];
- const entrust_zero = 0;
- const entrust_one = 1;
- const entrust_two = 2;
- const Entrust_Attribute = [
- self::entrust_zero => '无',
- self::entrust_one => '境内委托',
- self::entrust_two => '境外委托',
- ];
- const review_zero = 0;
- const review_one = 1;
- const Review_Attribute = [
- self::review_zero => '否',
- self::review_one => '是',
- ];
- // 引入自定义字段预加载关系
- use HasCustomFields;
- // 作用域 里面关联了客户自定义的表头数据 列表页需要 :: withCustomData($user) 这个是预加载
- public function scopeWithCustomData($query, $user)
- {
- $top_depart_id = $user['top_depart_id'];
- return $query->with(['customFields' => function ($subQuery) use ($top_depart_id) {
- $subQuery->where('top_depart_id', $top_depart_id)
- ->where('table_name', $this->table)
- ->where('del_time', 0);
- }]);
- }
- }
|