You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling ::allTenants() on a model that has not been booted I get the following error.
PHP error: Call to a member function newQueryWithoutTenants() on null in vendor/hipsterjazzbo/landlord/src/BelongsToTenants.php
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 a TenantManager.
I'm using the newest version of LandLord with Laravel 5.5.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: