I have my Model Job that has a relation to my model Location.
The Job table has 2 columns pickup and delivery and those 2 columns has a foreign key to my location table.
Now when I print the data of the Job model I get my array of pickup and delivery with their ID numbers but what I need is to get the name of the location and delivery which is in the location table.
I already tried this:
public function getJob()
{
return $this->hasOne(Job::className(), ['id' => 'job_id']);
}
public function getLocationName()
{
return $this->hasMany(Location::className(), ['location_id' => 'pickup_location'])
->via('job');
}
but that return only the name of the pickup_location but I also need the name of the delivery_location at the same time.