在模型[App \ Models \ Municipal_district]上调用未定义的关系[cities]

时间:2017-09-27 04:26:43

标签: laravel-5 laravel-eloquent laravel-5.5

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');
}

哪里可能出错?

1 个答案:

答案 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,区域属于一个城市。那么,这里的城市()是什么?