Undefined property in an "hasOne" relation
<p>I tried a lot of possibilities and I have all the time the same error.</p>

<p>Maybe you should help me... Hope so! I am working on Laravel 4.2</p>

<p>I have two tables :</p>

<p>users :</p>

<p>$table->increments('id');
 $table->string('email', 50);
...</p>

<p>account :</p>

<p>$table->increments('id');
 $table->integer('user_id')->unsigned();</p>

<p>I have 2 models :</p>

<p>User :</p>

<pre><code>public function account()
    {
        return $this-&gt;hasOne('Account', 'id','user_id');
    }
</code></pre>

<p>Account :</p>

<pre><code>public function user()
    {
        return $this-&gt;belongsTo('User', 'id');
    }
</code></pre>

<p>Now I would like to get the user_id in the account table by the relationship :</p>

<pre><code>$userId = Auth::id();
$account = User::find($userId)-&gt;Account()-&gt;user_id;
</code></pre>

<p>I get this error : ErrorException
Undefined property: Illuminate\Database\Eloquent\Relations\HasOne::$user_id</p>

<p>Could you help me?</p>

<p>Thank you in advance.</p>