<commit_before><?php namespace GlobeCode\LaravelMultiTenant;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\ScopeInterface;

use GlobeCode\LaravelMultiTenant\Exceptions\TenantIdNotSetException;

class TenantScope implements ScopeInterface {

    /**
     * Manually set the tenant id
     *
     * @var mixed int|null
     */
    protected static $tenantId = null;

    /**
     * Override the scope
     *
     * @var boolean
     */
    protected static $override = false;

    /**
     * All of the extensions to be added to the builder.
     *
     * @var array
     */
    protected $extensions = ['RemoveTenant', 'ApplyTenant', 'AllTenants'];

    /**
     * Apply the scope to a given Eloquent query builder.
     *
     * @param  \Illuminate\Database\Eloquent\Builder $builder
     *
     * @throws Exceptions\TenantIdNotSetException
     * @return void
     */
    public function apply(Builder $builder)
    {
        if (self::getOverride() === false)
        {
            $tenantId = (int) trim(self::getTenantId());

            if (is_null($tenantId) || empty($tenantId) || $tenantId < 1)
                throw new TenantIdNotSetException;

            $model = $builder->getModel();

            // Apply the scope to the Model's Builder
            $builder->where($model->getQualifiedTenantColumn(), $tenantId);
        }

        // Make extensions available, even if 'overriding'.
        $this->extend($builder);
    }

    /**
     * Remove the scope from the given Eloquent query builder.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
     * @return void
     */
    public function remove(Builder $builder)
    {
        $column = $builder->getModel()->getQualifiedTenantColumn();

        // Illuminate/Database/Query/Builder.php
        $query = $builder->getQuery();

        // Array of all binding types, including 'where'
        $bindings = $query->getRawBindings();
<commit_msg>Removed (int) to enable tenant_id field to be Uuid<commit_after><?php namespace GlobeCode\LaravelMultiTenant;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\ScopeInterface;

use GlobeCode\LaravelMultiTenant\Exceptions\TenantIdNotSetException;

class TenantScope implements ScopeInterface {

    /**
     * Manually set the tenant id
     *
     * @var mixed int|null
     */
    protected static $tenantId = null;

    /**
     * Override the scope
     *
     * @var boolean
     */
    protected static $override = false;

    /**
     * All of the extensions to be added to the builder.
     *
     * @var array
     */
    protected $extensions = ['RemoveTenant', 'ApplyTenant', 'AllTenants'];

    /**
     * Apply the scope to a given Eloquent query builder.
     *
     * @param  \Illuminate\Database\Eloquent\Builder $builder
     *
     * @throws Exceptions\TenantIdNotSetException
     * @return void
     */
    public function apply(Builder $builder)
    {
        if (self::getOverride() === false)
        {
            $tenantId = trim(self::getTenantId());

            if (is_null($tenantId) || empty($tenantId) || $tenantId < 1)
                throw new TenantIdNotSetException;

            $model = $builder->getModel();

            // Apply the scope to the Model's Builder
            $builder->where($model->getQualifiedTenantColumn(), $tenantId);
        }

        // Make extensions available, even if 'overriding'.
        $this->extend($builder);
    }

    /**
     * Remove the scope from the given Eloquent query builder.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
     * @return void
     */
    public function remove(Builder $builder)
    {
        $column = $builder->getModel()->getQualifiedTenantColumn();

        // Illuminate/Database/Query/Builder.php
        $query = $builder->getQuery();

        // Array of all binding types, including 'where'
        $bindings = $query->getRawBindings();

{'fraction_non_alphanumeric': 0.1152388172858226, 'fraction_numerical': 0.0005054334091483447, 'mean_word_length': 2.3656462585034013, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '522363', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1141, 'n_words': 277}