I'm sorry my English is not good.
I need get 2 city name with once query:
For example:
City table:
+---------+----------+
| Pana | Name |
+---------+----------+
| THR | Tehran |
| LON | London |
+---------+----------+
In Model: [from_city
is THR and to_city
is LON]
public function scopePrintQuery($query, $id)
{
$join = $query
-> join('cities', 'cities.pana', 'flights.from_city')
-> join('cities', 'cities.pana', 'flights.to_city')
-> where('flights.id', $id)
->get([
'flights.*',
'cities.name as from_city'
??? for to_city?
]);
return $join;
}
Now, I need get from_city
name and to_city
name this query. In query dose not work 2 join from one table !
How to create query?
via mySun