title: Call to a member function all() on null
body: <p>I had relationship made that is User and UserDetail.php</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class User extends Model
  {
      protected $table ='users';
  
      protected $fillable = ['name', 'email', 'password'];
  
      public function user(){
          return $this-&gt;hasOne('App\UserDetail');
      }
  }
  </code></pre>
  
  <p>UserDetail.php
    
  
  <pre><code>namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class UserDetail extends Model
  {
      protected $table ='user_details';
  
      protected $fillable = ['user_id', 'address', 'gender'];
  
      public function user(){
          return $this-&gt;belongsTo('App\User');
      }
  }
  </code></pre>
  
  <p>but when I call it in the controller</p>
  
  <pre><code>  public function showUserInformation($id){
      $details= $this-&gt;user-&gt;detail;
      dd($details);
    }
  </code></pre>
  
  <blockquote>
    <p>it returns null when I dd it. why was it happening?  Kindly help me
    please</p>
  </blockquote>