mercredi 16 mars 2016

BelongsTo is not working whereas hasMany is working in Laravel 5.2

I have Two tables

1) countries 2) affiliates

The models are Country.php and Affiliate.php

countries table :

id
name
etc..

affiliates table

id
name
country_id
etc..

Now my Model methods

Affiliate.php

public function Country() {
   return $this->belongsTo('App\Country');
}

Country.php

public function Affiliates() {
  return $this->hasMany('App\Affiliate');
}

For me, Affiliates is returning correct results but Country is returning null



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire