- DepartmentUser: Model → Pivot 상속 변경 (fromRawAttributes 에러 수정) - Department: BelongsToTenant 트레이트 추가 (테넌트 필터링) - Department.employees(): tenant_user_profiles 기반 사원 조회 관계 추가 - DepartmentService.tree(): department_user 대신 employees 사용 - users 형태로 변환하여 프론트엔드 호환성 유지 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Tenants\Pivots;
|
|
|
|
use App\Models\Commons\IdeHelperDepartmentUser;
|
|
use App\Models\Members\User;
|
|
use App\Models\Tenants\Department;
|
|
use App\Traits\BelongsToTenant;
|
|
use App\Traits\ModelTrait;
|
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* @mixin IdeHelperDepartmentUser
|
|
*/
|
|
class DepartmentUser extends Pivot
|
|
{
|
|
use BelongsToTenant, ModelTrait, SoftDeletes;
|
|
|
|
protected $table = 'department_user';
|
|
|
|
protected $fillable = [
|
|
'tenant_id', 'department_id', 'user_id', 'is_primary', 'joined_at', 'left_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'tenant_id' => 'integer',
|
|
'department_id' => 'integer',
|
|
'user_id' => 'integer',
|
|
'is_primary' => 'integer',
|
|
'joined_at' => 'datetime',
|
|
'left_at' => 'datetime',
|
|
];
|
|
|
|
public function department()
|
|
{
|
|
return $this->belongsTo(Department::class, 'department_id');
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
}
|