I have three tables, one of them is pivot table (and pivot model) and trying to create belongsTo relationship in pivot model (foreign key in pivot table) so that I can get the relevant name from some other table(has primary key). What I want to do is illustrating by images below:
Pivot Table is:
And other table is:
It is pivot Model:
class MproductIngredient extends Model {
public function qtyType() {
return $this->belongsTo('App\TIngredientType','priQuantityTypeNo');
}
}
How to get the relevant name from other table(has primary key).
My code is:
@foreach($prd->ingredients a $ingredient)
"{!! $ingredient->pivot->priQuantityTypeNo !!}"
@endforeach