Detailing fungsi semua modul dari bugs error
This commit is contained in:
+10
-2
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user