City.php
public function municipal_districts()
{
return $this->hasMany('App\Models\Municipal_district');
}
Municipal_district.php
public function province()
{
return $this->belongsTo('App\Models\City', 'city_id');
}
哪里可能出错?
答案 0 :(得分:1)
城市模型
public function municipal_districts()
{
return $this->hasMany('App\Models\Municipal_district');
}
Municipal_district模型
public function city()
{
return $this->belongsTo('App\Models\City', 'city_id');
}
我不知道这里的城市()关系!
城市有很多ditricts,区域属于一个城市。那么,这里的城市()是什么?