You should have two models tableA and TableB, since the tableB key is included with tableA that means the tableA belongs to tableB . If relation is one to one use haseOne if one to many use hasMany
class TableB extends Eloquent {
...
public function tableA(){
return $this->hasOne('TableA');
}
...
}
class TableA extends Eloquent {
...
public function tableB(){
return $this->belongsTo('TableB');
}
...
}
Ya, I get that. But that works with 1 column in each table right? Here I have 1 column in TableB that is related to 2 columns in TableA.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community