title: Obtaining data using model relationships in Laravel
body: <p>I am developing an application for the first time using Laravel. I need to fill a form using model-form binding which requires passing the data to the form.</p>
  
  <p>Now the data which I need to pass is in a table called "teachers". It has corresponding Model and Controller both. The users table is the standard Laravel table. The users and teachers are related via "email". I tested the relashionships on Tinker which shows desired output as follows.</p>
  
  <blockquote>
    <p>>>> <strong>$user = App\User::find(15);</strong><br>
    => App\User {#2947<br>
         id: 15,<br>
         name: "First",<br>
         email: "first@example.com",<br>
         email_verified_at: null,<br>
         created_at: "2019-04-19 17:10:59",<br>
         updated_at: "2019-04-19 17:10:59",    }<br>
    >>> <strong>$user->teacher</strong><br>
    => App\teacher {#2948<br>
         sdrn: 856,<br>
         name: "First",<br>
         surname: null,<br>
         deptname: null,<br>
         deptcode: null,<br>
         designation: null,<br>
         email: "first@example.com",<br>
         mobile: null,<br>
         cc: "N",<br>
         created_at: "2019-04-19 17:10:59",<br>
         updated_at: "2019-04-19 17:10:59",    }<br></p>
  </blockquote>
  
  <p>Thus, the relationships are working alirght since the tinker commands are bringing correct row from teachers table.</p>
  
  <p>However when I get the logged in teacher via Auth library as </p>
  
  <pre><code> $user = Auth::user();
   $teacher = $user-&gt;teacher();
   dd();
  </code></pre>
  
  <p>the output of dd() shows something like</p>
  
  <blockquote>
    <p>BelongsTo {#270 ▼ <br>   #child: User {#273 ▶}<br>   #foreignKey:
    "email"<br>   #ownerKey: "email"<br>   #relationName: "teacher"<br>  #query: Builder {#267 ▶}<br>   #parent: User {#273 ▶}<br>   #related: teacher {#262 ▶}<br>   #withDefault: null<br> }</p>
  </blockquote>
  
  <p>This is not what I need. I need to pass the corresponding row from teachers table to the form. Tinker gives the desired result alright but the <code>Auth:user()</code> is returning some funny object.</p>
  
  <p>What am I missing?</p>