[Добавлено]: Вывод всех врачей при создании отчета #2

This commit is contained in:
brusnitsyn
2026-06-04 17:55:24 +09:00
parent ee6b13d447
commit 0a6af0a315
3 changed files with 23 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ class Department extends Model
public function userDepartment()
{
return $this->belongsTo(UserDepartment::class, 'rf_department_id', 'department_id');
return $this->belongsTo(UserDepartment::class, 'department_id', 'rf_department_id');
}
public function recipientPlanOfYear()

View File

@@ -68,6 +68,19 @@ class User extends Authenticatable
return $this->hasMany(UserDepartment::class, 'rf_user_id', 'id')->orderBy('order');
}
public function misDepartments()
{
return $this->belongsToMany(
Department::class, // конечная модель
'user_departments', // промежуточная таблица
'rf_user_id', // внешний ключ в промежуточной таблице на User
'rf_department_id', // внешний ключ в промежуточной таблице на Department
'id', // локальный ключ в User
'department_id' // локальный ключ в Department (уточните имя!)
)->withPivot('order') // если нужен order
->orderBy('user_departments.order');
}
public function favoriteDepartment()
{
return $this->department()->where('is_favorited', true);