laravel - Querying with Eloquent - Achieve Join -
how select records db situation below using eloquent
tables:
employee table [ id,name]
address table [id,address_line1,employee_id,city_id]
city table [id,name]
a query below return city id, need city name well
$employee = employee::with('address')->get();
and employee model have relationship
public function address(){ $this->hasmany('address'); }
how achieve desired result output of query should give me city name city table, based on id address table, without running new query each city id names
Comments
Post a Comment