I need get two city names with one query:
For example:
City table:
+---------+----------+
| Pana | Name |
+---------+----------+
| T
you can also use the eloquent model with defining the relationship.
Also for more detail visit https://laravel.com/docs/5.3/eloquent-relationships
crate two model -- 1st is "Flights"
hasOne('App\Models\City', 'Pana', 'from_city');
}
/**
* Get the To city state.
*/
public function toCity()
{
return $this->hasOne('App\Models\City', 'Pana', 'to_city');
}
}
2nd Model is "City"
Now for fetching
Flights::where(id, $id)->with('toCity', 'fromCity')->get();