2025-08-16 03:25:06 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Commons;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
|
|
|
use App\Traits\ModelTrait;
|
2025-08-21 09:50:15 +09:00
|
|
|
use App\Models\Members\User;
|
2025-08-16 03:25:06 +09:00
|
|
|
|
2025-08-21 09:50:15 +09:00
|
|
|
/**
|
|
|
|
|
* @mixin IdeHelperDepartmentUser
|
|
|
|
|
*/
|
2025-08-16 03:25:06 +09:00
|
|
|
class DepartmentUser extends Model
|
|
|
|
|
{
|
|
|
|
|
use SoftDeletes, BelongsToTenant, ModelTrait;
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
// User 네임스페이스가 다르면 여기만 맞춰줘.
|
2025-08-21 09:50:15 +09:00
|
|
|
return $this->belongsTo(User::class, 'user_id');
|
2025-08-16 03:25:06 +09:00
|
|
|
}
|
|
|
|
|
}
|