调用模型 [App\Models\Municipal_district] 上的未定义关系 [城市]
Call to undefined relationship [cities] on model [App\Models\Municipal_district]
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');
}
哪里会出错?
城市模式
public function municipal_districts()
{
return $this->hasMany('App\Models\Municipal_district');
}
Municipal_district型号
public function city()
{
return $this->belongsTo('App\Models\City', 'city_id');
}
而且我不知道这里的 cities() 关系!
市有多个区,区属于一个市。那么,这里的 cities() 是什么?
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');
}
哪里会出错?
城市模式
public function municipal_districts()
{
return $this->hasMany('App\Models\Municipal_district');
}
Municipal_district型号
public function city()
{
return $this->belongsTo('App\Models\City', 'city_id');
}
而且我不知道这里的 cities() 关系!
市有多个区,区属于一个市。那么,这里的 cities() 是什么?