'未确认', self::STATE_ONE => '已确认', ]; const Order_type_one = 1;//普通采购 const Order_type_two = 2;//代发采购 const Order_type_three = 3;//采购施工(安装费) public static $order_type = [ self::Order_type_one => '普通采购', self::Order_type_two => '代发采购', self::Order_type_three => '采购施工(安装费)' ]; public static $user = []; public static $search = []; public static $is_search = false; const range_function = 'purchaseRange'; public function __construct(array $attributes = []) { if(! empty($attributes['userData'])) { self::$user = $attributes['userData']; self::$search = $attributes['search'] ?? []; self::$user['range_function'] = self::range_function; self::$is_search = true; } parent::__construct($attributes); } protected static function boot(){ parent::boot(); if(self::$is_search){ static::addGlobalScope(new DepartmentScope(self::$user, self::$search)); } } }