'退货单', self::Model_type_two => '换货单', ]; const State_zero = 0;//未确认 const State_one = 1;//已确认 public static $state = [ self::State_zero => '未确认', self::State_one => '已确认', ]; public static $prefix = [ self::Model_type_one => 'TH', self::Model_type_two => 'HH', ]; public static $user = []; public static $search = []; public static $is_search = false; public function __construct(array $attributes = []) { if(! empty($attributes['userData'])) { self::$user = $attributes['userData']; self::$search = $attributes['search']; 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)); } } }