title: Laravel 8 belongsTo relationship not returning data on User model
body: <p>I'm building a Laravel 8 API and want to automatically join <code>user_settings</code> onto a <code>user</code> whenever the <code>User</code> model is queried.</p>
  <p>My thinking is that I can achieve this with the <a href="https://laravel.com/docs/8.x/eloquent-relationships#one-to-many-inverse" rel="nofollow noreferrer">belongsTo</a> relationship since <code>user_settings</code> &quot;belongs&quot; to a user.</p>
  <p>However, when I attach this to my <code>UserSetting</code> model and query a user I'm not seeing any user settings attached to my User despite having data in the <code>user_settings</code> table.</p>
  <p>Where am I going wrong?</p>
  <p><strong>Model: <code>User</code></strong></p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Database\Eloquent\Model;
  use Illuminate\Database\Eloquent\SoftDeletes;
  
  class UserSetting extends Model
  {
      use HasFactory, SoftDeletes;
  
      /**
      * The table associated with the model.
      *
      * @var string
      */
      protected $table = 'user_settings';
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'user_id',
          'theme',
          'refreshButtonPlacement',
          'animationSpeed',
          'fetchTimeout'
      ];
  
      /**
       * Get the user that owns the comment.
       */
      public function user()
      {
          return $this-&gt;belongsTo(UserSetting::class);
      }
  }
  </code></pre>
  <p><strong>Model: <code>User</code></strong></p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Database\Eloquent\SoftDeletes;
  
  use Illuminate\Database\Eloquent\Model;
  use Tymon\JWTAuth\Contracts\JWTSubject;
  
  
  class User extends Authenticatable implements JWTSubject
  {
      use HasFactory, Notifiable, SoftDeletes;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'first_name',
          'last_name',
          'email',
          'password',
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password'
      ];
  
      /**
       * The attributes that should be cast to native types.
       *
       * @var array
       */
      protected $casts = [
          'email_verified_at' =&gt; 'datetime',
          'last_login_at' =&gt; 'datetime'
      ];
  
      /**
       * Get the identifier that will be stored in the subject claim of the JWT.
       *
       * @return mixed
       */
      public function getJWTIdentifier()
      {
          return $this-&gt;getKey();
      }
  
      /**
       * Return a key value array, containing any custom claims to be added to the JWT.
       *
       * @return array
       */
      public function getJWTCustomClaims()
      {
          return [];
      }
  }
  </code></pre>
  <p>I also tried using a <a href="https://laravel.com/docs/8.x/eloquent-relationships#one-to-one" rel="nofollow noreferrer">One To One</a> relationship and defined a <code>settings</code> method on my <code>User</code> model but in Tinker when I ran <code>User::findOrFail(1)-&gt;settings;</code> I had nothing either.</p>