fix : Member 모델에서 User 모델로 변경
This commit is contained in:
@@ -2,23 +2,31 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use App\Traits\ModelTrait;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, Notifiable, TwoFactorAuthenticatable, SoftDeletes;
|
||||
use HasApiTokens, Notifiable, TwoFactorAuthenticatable, SoftDeletes, ModelTrait;
|
||||
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
'two_factor_secret', 'two_factor_recovery_codes', 'two_factor_confirmed_at'
|
||||
];
|
||||
|
||||
public function userTenants()
|
||||
{
|
||||
return $this->hasMany(UserTenant::class);
|
||||
}
|
||||
|
||||
public function tenants()
|
||||
public function userTenant() // 단일 기본 테넌트
|
||||
{
|
||||
return $this->belongsToMany(Tenant::class, 'user_tenants');
|
||||
// 예시: 첫 번째(기본) 테넌트 반환
|
||||
return $this->hasOne(UserTenant::class)->where('is_active', 1);
|
||||
}
|
||||
|
||||
public function userRoles()
|
||||
@@ -31,4 +39,9 @@ public function roles()
|
||||
return $this->belongsToMany(Role::class, 'user_roles')
|
||||
->withPivot('tenant_id', 'assigned_at');
|
||||
}
|
||||
|
||||
public function userTenantById($tenantId)
|
||||
{
|
||||
return $this->hasOne(UserTenant::class)->where('tenant_id', $tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user