I have a pivot table with the following columns in a pivot table for my many-to-many relationship between the manifest class and the customer class, I have added the field "transferAgent" to pull details from another model:
-carrier_manifest_id
-shipment_id
-transferAgent
-created_at
-updated_at
At the moment this is the base of the relationship from the manifest class:
public function shipments(){
return $this->belongsToMany(Shipment::class, 'carrier_manifest_shipment')->withPivot('notes', 'transfer','transferAgent','owb','bnf')->withTimestamps();
}
Now, when this was designed in the past, the transferAgent field had been setup in the shipment class and the relationship was defined like such:
public function transferAgentDetails(){
return $this->belongsTo('App\Customer', 'transferAgent','id');
}
So how would I go about adding the ability to use a the relationship between the pivot table and the Customer model through the transferAgent field?
And then on my blade for example, there is a name field in the customer class, would I pull that name onto my blade like this?
or would it be through another method?
Thanks!
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2p7sVW2
via IFTTT
Aucun commentaire:
Enregistrer un commentaire