Coder Social home page Coder Social logo

Comments (4)

bradenkeith avatar bradenkeith commented on June 21, 2024

from multitenancy.

devonmather avatar devonmather commented on June 21, 2024

Thanks for replying to this on the weekend. I can confirm the trait is on the model.

I have echoed out the apply method to see if it was exiting early or anything.

public function applyTenantScope(Model $model)
{
    echo 'reached 1, ';
    if (is_null($this->tenant)) {
        $this->deferredModels->push($model);

        return;
    }
    
    echo 'reached 2, ';
    if ($this->tenant->domain === 'admin') {
        return;
    }

    echo 'reached 3, ';
    $model->addGlobalScope('tenant', function (Builder $builder) use ($model) {
        echo 'reached 4, ';
        $builder->where($model->qualifyColumn('tenant_id'), '=', $this->tenant->id);
    });
    echo 'reached 5, ';
}

That results in the following output "reached 1, reached 1, reached 2, reached 3, reached 5,"

For some reason the addGlobalScope function is not being invoked?

from multitenancy.

devonmather avatar devonmather commented on June 21, 2024

Is there any reason this function would be skipped?

$model->addGlobalScope('tenant', function (Builder $builder) use ($model)

from multitenancy.

bradenkeith avatar bradenkeith commented on June 21, 2024

When setup correctly, I can't imagine an instance where that'd be the case. If you are able to provide a repo of your code, I can review it and see where things are going wrong!

from multitenancy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.