According to your table relation below
User
--------
id name country_id
1 Hakan 1
Country
--------
id country
1 Turkey
Your relation in the model should be
class User extends Eloquent{
public function country() {
return $this->belongsTo('Country');
}
}
So you can get country name using
$country = User::find(1)->country;
echo $country->country;
If you want to use something like this
$users = Country::find(1)->users;
echo $users->first()->name; // get the first user's name
echo $users->get(1)->name; // get the second user's name
Then you may use hasMany
in your Country
model like
class Country extends Eloquent {
public function users()
{
return $this->hasMany('User');
}
}