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
I am unable to get $tenantColumns to set/change the column used for tenant lookup. I want to use this to change the column used for tenant in one of my tables.
public $tenantColumns = ['id'];
I have logged what tenantColumn is set to by using
$tenants = Landlord::getTenants();
I have set my default $tenantColumns in config and I set the scoped tenant in middleware.
Here is my model (shortened for clarity) where i am trying to change the $tenantColumn.
<?php
namespace App\Models\Admin;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use HipsterJazzbo\Landlord\BelongsToTenants;
class company extends Model
{
use SoftDeletes;
use BelongsToTenants;
public $tenantColumns = ['id'];
...
One thing possibly worth noting is I was unable to successfully addTenant without clearing booted models before addTennant was called.
My middle wear looks as follows:
Notice the addition of \Illuminate\Database\Eloquent\Model::clearBootedModels();
This was used as per instructions here: #64
I wonder is this same issue is affecting my ability to set $tenantColumns.
use Closure;
use Sentinel;
use HipsterJazzbo\Landlord\Facades\Landlord;
use Illuminate\Support\Facades\Auth;
class Tenancy
{
public function handle($request, Closure $next)
{
if (!Sentinel::check()) {
return redirect('login')->with('info', 'You must be logged in!');
}
else {
\Illuminate\Database\Eloquent\Model::clearBootedModels();
Landlord::addTenant('company_id', $request->user()->company_id);
return $next($request);
}
}
}
Thanks for any assistance.
The text was updated successfully, but these errors were encountered:
I am unable to get $tenantColumns to set/change the column used for tenant lookup. I want to use this to change the column used for tenant in one of my tables.
public $tenantColumns = ['id'];
I have logged what tenantColumn is set to by using
$tenants = Landlord::getTenants();
I have set my default $tenantColumns in config and I set the scoped tenant in middleware.
Here is my model (shortened for clarity) where i am trying to change the $tenantColumn.
One thing possibly worth noting is I was unable to successfully addTenant without clearing booted models before addTennant was called.
My middle wear looks as follows:
Notice the addition of \Illuminate\Database\Eloquent\Model::clearBootedModels();
This was used as per instructions here: #64
I wonder is this same issue is affecting my ability to set $tenantColumns.
Thanks for any assistance.
The text was updated successfully, but these errors were encountered: