Try this:
public function masterOf (){
return $this->belongsToMany('Fighter', 'fighter_fighter', 'fighter_id', 'fighter_id_mestre');
}
public function trainedBy(){
return $this->belongsToMany('Fighter', 'fighter_fighter', 'fighter_id_mestre', 'fighter_id');
}
Anyway, maybe is better to rename table with something like "fighter_training" ;)
NeiPCs said:
Try this:
public function masterOf (){ return $this->belongsToMany('Fighter', 'fighter_fighter', 'fighter_id', 'fighter_id_mestre'); } public function trainedBy(){ return $this->belongsToMany('Fighter', 'fighter_fighter', 'fighter_id_mestre', 'fighter_id'); }
Anyway, maybe is better to rename table with something like "fighter_training" ;)
Thank you so much, man. I was facing the same problem and this solved it. I already knew how to override the fields but was strugling on how to determine which would be the pivot in this kind of many-to-many self-relation using the ORM.
Cheers.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community