Add a global scope to the model. But we have to handle the different
scenario, as Laravel 5.1 has a different way compared to all other
versions.

@param  string  $type
@return void
7111
protected static function handleGlobalScope($type)
    {
        if (Eye::laravelVersionIs('>=', '5.2.0')) {
            static::addGlobalScope('type', function (Builder $builder) use ($type) {
                $builder->where('type', $type);
            });
        } else {
            static::addGlobalScope(new TypeLegacy($type));
        }

    }
271149
public function addType(string $name, string $type): void{
        $this->types[$name] = new Type($type);
    }
830482
public function add(string $type, string $value): void
    {
        if ($this->entry[$type] === null) {
            $this->entry[$type] = array();
        }
        $this->entry[$type] = (array) $this->entry[$type];
        $this->entry[$type][] = $value;
    }
459844
public function onAddedToType(TypeInterface &$type)
    {
        parent::onAddedToType($type);

        if ($this->getAddIndex()) {
            $index_fields = [$this->name];

            if (count($this->getAddIndexContext())) {
                $index_fields = array_merge($index_fields, $this->getAddIndexContext());
            }

            $type->addIndex(new Index($this->name, $index_fields, $this->getAddIndexType()));
        }
    }
898683
public function onAddedToType(TypeInterface &$type)
    {
        parent::onAddedToType($type);

        $type->addTrait(IsArchivedInterface::class, IsArchivedInterfaceImplementation::class)->serialize($this->getName());
    }
600913
public function skipUntil(int $type): void
    {
        while (!$this->current->typeEquals($type) && !$this->current->typeEquals(Token::T_EOI)) {
            $this->next();
        }
    }
1204155
public function addType($type)
    {
        if (func_num_args() > 1) {
            foreach (func_get_args() as $t) {
                $this->addType($t);
            }
        } else {
            if (is_array($type)) {
                foreach ($type as $t) {
                    $this->addType($t);
                }
            } else {
                if (!$this->typeIsAvailable($type)) {
                    $this->types[] = $type;
                }
            }
        }

        return $this;
    }
1141503
public function optionUpdate($type = null)
    {
        if (in_array($type, ['modules', 'languages'])) {
            switch ($type) {
                case 'modules':
                    modules()->updateRegistry();
                    break;

                case 'languages':
                    language()->updateRegistry();
                    break;
            }
        } else {
            modules()->updateRegistry();
            language()->updateRegistry();
        }

        exit(EXIT_SUCCESS);
    }
1103548
public function setType($type)
    {
        switch ($type) {
            case self::TYPE_CSV:
                $this->headers->add(array('Content-Type' => 'text/csv;charset=' . self::UTF_16_LE));
                break;
            case self::TYPE_XLS:
                $this->headers->add(array("Content-Type" => "application/vnd.ms-excel"));
                break;
        }
        $this->type = $type;
    }
849556
public function registerAsSingleton(string $type): self
    {
        $this->typeDefinition->register($type, true);
        return $this;
    }
1362896
public function set_caching($type)
    {
        if ($type) {
            $this->caching = $type;
        }
        else {
            if ($this->cache) {
                $this->cache->close();
            }
            $this->cache   = null;
            $this->caching = false;
        }
    }
1374452
public function setType($type)
    {
        $const = sprintf('%s::TYPE_%s', __CLASS__, strtoupper($type));
        
        if(defined($const))
        {
            $type = constant($const);
        }
        
        $this->setAttributeDirectly('type', $type);
        
        $this->enumerationStrategy = null;
    }
1147266
public function setType($type)
    {
        if (in_array($type, array_keys($this->devices))) {
            $this->type = $type;
        }
    }
289421
public function addDisallowedType($type)
    {
        if (!in_array(strtolower($type), $this->disallowedTypes)) {
            $this->disallowedTypes[] = strtolower($type);
        }
        return $this;
    }
951073
public function addCredential($type)
    {
        $this->data_type = $type;

        $this->setTitleEditCredential();
        $this->setBreadcrumbEditCredential();

        $this->credential->callHandler($type, 'edit');
    }
725810
public function setInheritanceType($type)
    {
        if ( ! $this->_isInheritanceType($type)) {
            throw MappingException::invalidInheritanceType($this->name, $type);
        }
        $this->inheritanceType = $type;
    }
409265
public function setType(string $type): void {
		if ($this->compiled) {
			throw new ResponseException("Attempt to alter response after compilation.", ResponseException::AFTER_COMPILE_ALTERATION);
		}
		
		$type = strtolower($type);
		
		if (!in_array($type, ["html", "json", "text", "redirect"])) {
			throw new ResponseException("Unexpected response type: $type.", ResponseException::UNKNOWN_RESPONSE_TYPE);
		}
		
		$this->type = $type;
	}