i have 3 table
- hotel
- province
- city
hotel have relation to city and city have relation to province. city id will save in city filed in hotel table. how can i access city name and province name in Hotel model?
in hotel model i wrote this :
public function city(){
return $this->belongsTo(City::class);
}
and in city model i have this:
public function hotel(){
return $this->hasMany(Hotel::class);
}
public function province(){
return $this->belongsTo(Province::class);
}
and in province
public function cities(){
return $this->hasMany(City::class);
}
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2MfopTP
via IFTTT
Aucun commentaire:
Enregistrer un commentaire