I have two models Studentand one StudentRevisionwith a model Studentrelated hasManyto the model StudentRevision. I determined the ratio hasManyin Studentboth
public function revisions()
{
return $this->hasMany(
'StudentRevision',
'sid'
);
}
I have a field in the student table (student model) that refers to the current revision of the student from the student_revisions table .
The table structure looks something like this.
students sid srid name ....
student_revisions package srid sid ....
Now I want to determine the relationship hasOneto the model StudentRevisionthat refers to the current revisionone associated with Student. I have currently defined this relationship as:
public function current()
{
return $this->hasOne(
'StudentRevision',
'sid'
)
->where('srid', $this->srid);
}
, $this->srid , .
, , .