Detailing fungsi semua modul dari bugs error

This commit is contained in:
Iwit
2026-06-05 13:39:13 +07:00
parent 1089f60a3d
commit 6a79bc3464
31 changed files with 1927 additions and 228 deletions
+10 -2
View File
@@ -73,10 +73,18 @@ class User extends Authenticatable
return $this->belongsTo(Position::class, 'position_id');
}
public function subjects()
{
// Parameter ke-3 'user_id' akan memaksa Laravel mengabaikan pencarian 'employee_id'
return $this->belongsToMany(\App\Models\Subject::class, 'employee_subject', 'user_id', 'subject_id')
->withPivot('status')
->withTimestamps();
}
public function trainings()
{
// Ubah 'user_id' menjadi 'employee_id' agar sesuai dengan database Anda saat ini
return $this->belongsToMany(Subject::class, 'employee_subject', 'employee_id', 'subject_id')
// Karena ini Model User, foreign key-nya harus 'user_id'
return $this->belongsToMany(Subject::class, 'employee_subject', 'user_id', 'subject_id')
->withPivot('status')
->withTimestamps();
}