How to convert the following query to eloquent model in Laravel 5?
$city = DB::table('cities')
->join('provinces', 'cities.province_id', '=', 'provinces.id')
->join('countries', 'provinces.country_id', '=', 'countries.id')
->select('cities.name as City','provinces.name as Province','countries.name as Country')
->where('cities.isDelete', '=', '0')
->get();
My table structures are:
Country: id, name
Province: id, name, country_id
City: id, name, province_id
I've done working with the eloquent model with 2 tables but I don't know how to manage 3 tables. P.S. I have properly defined my relationships in model.
Aucun commentaire:
Enregistrer un commentaire