0
私は、このようなこのコードなどの2つのモデルがあります。今、私はこのコードを使用して、その都市のすべての国をフェッチするためにトリングいなぜlaravelでRelationNotFoundExceptionが発生していますか?
class City extends Model
{
protected $table = 'city';
protected $fillable = array("name");
}
:
$countries = Country::all();
$countries->load('App\City');
return json_encode($countries);
または
class Country extends Model
{
protected $table = 'country';
public function cities(){
return $this->hasMany('App\City');
}
}
とをこのワン:
Country::with("App\City")->get();
が、私はこの例外を取得しています:モデルの未定義の関係に
コール[アプリケーション\市] [APP \国]
私が代わりに「アプリケーション\市の "市" と "街" を試しますしかし、鉄鋼の例外は残っている。私のミスはどこにありますか?どのようにしてこの問題を解決できますか?