title: Laravel belongsTo ignoring foreign key
body: <p>I have 2 models, User and Task.</p>
  
  <p>Task.php:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Task extends Model
  {
      //  
     protected $fillable=['text','title','user_id','completed','created_by'];
     public function users()
     {
          return $this-&gt;belongsTo(User::class, 'id');
     }
  
  }
  </code></pre>
  
  <p>and User.php:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Notifications\Notifiable;
  use Illuminate\Contracts\Auth\MustVerifyEmail;
  use Illuminate\Foundation\Auth\User as Authenticatable;
  
  class User extends Authenticatable
  {
      use Notifiable;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'name', 'email', 'password',
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'remember_token',
      ];
      public function tasks()
      {
          return $this-&gt;hasMany(Task::class);
      }
  }
  </code></pre>
  
  <p>My objective here is to have every task assigned to a user so I can retrieve the name of the user that created that task.<br>
  The users table has id and name columns. The task table also has an id column.<br>
  So how can I get the name of the user that created a task using eloquent relationships?<br></p>
  
  <pre><code>App\User::first()-&gt;tasks
  </code></pre>
  
  <p>gives:</p>
  
  <pre><code>Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tasks.user_id' in 'where clause' (SQL: select * from `tasks` where `tasks`.`user_id` = 1 and `tasks`.`user_id` is not null)'
  </code></pre>