Replies: 3 comments 1 reply
-
I don’t have the magic ball, please post your code. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Pktharindu\NovaPermissions\Traits\HasRoles;
use Spatie\Multitenancy\Models\Concerns\UsesTenantConnection;
use Spatie\Multitenancy\Models\Tenant;
class User extends Authenticatable
{
use UsesTenantConnection;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public static function boot()
{
parent::boot();
Tenant::checkCurrent() ;
static::saving(function ($model) {
$tenant = Tenant::current();
\Log::info('tenant = ' . $tenant);
});
static::creating(function ($model) {
$tenant = Tenant::current();
\Log::info('tenant = ' . $tenant);
});
}
} |
Beta Was this translation helpful? Give feedback.
-
when i read a model,it from tenant, yes, its ok
but when i save to database, it save to landlord.
can u tell me what happed?thanks.
Beta Was this translation helpful? Give feedback.
All reactions