Revert "fix : User 모델 경로 오류로 인해 User 모델만 밖으로 이동"

This reverts commit 2b82483f64.
This commit is contained in:
2025-07-29 16:04:28 +09:00
parent 2b82483f64
commit 7d607471b8
25 changed files with 24 additions and 29 deletions

View File

@@ -0,0 +1,53 @@
<?php
namespace App\Models\Members;
use App\Models\Commons\Role;
use App\Models\File;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, Notifiable, 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 userTenant() // 단일 기본 테넌트
{
// 예시: 첫 번째(기본) 테넌트 반환
return $this->hasOne(UserTenant::class)->where('is_active', 1);
}
public function userRoles()
{
return $this->hasMany(UserRole::class);
}
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);
}
public function files()
{
return $this->morphMany(File::class, 'fileable');
}
}