hipsterjazzbo / Landlord

A simple, single database multi-tenancy solution for Laravel 5.2+
MIT License
612 stars 142 forks source link

Scope is not applied when model is instantiated via dependency injection within controller #106

Open booni3 opened 5 years ago

booni3 commented 5 years ago

The tenant scope is not applied when instantiating the model as follows:

class OrderController extends Controller
{
    protected $order;

    public function __construct(Order $order)
    {
        $this->order = $order;
    }

...

but...

Order::all() // works fine

This is not a huge issue, when you know this is the case, but does anyone know why or of any work arounds to it?

jiriko commented 5 years ago

Maybe you can move the \Illuminate\Routing\Middleware\SubstituteBindings::class away from the global middleware and set it after your Landlord middleware.