Open rikvdlooi opened 7 years ago
I see a PR was created to fix this. Pull Request #75
Workaround for people stumbling upon this: instantiate the model you want to call allTenants()
on. Example:
use App\Books;
public function getAllBooks()
{
// Workaround to call boot method, needed for Landlord to work correctly.
new Books;
return Books::allTenants()->get();
}
When calling
::allTenants()
on a model that has not been booted I get the following error.I found that this is due to that the Model has not yet booted (it was never instantiated). This means the
bootBelongsToTenants()
will never get called, so in turn$landlord
will never be set to aTenantManager
.I'm using the newest version of LandLord with Laravel 5.5.