auto fill foreign key for models that does not have "name_id" format.

users

  • id
  • name

comments

  • created_by_id
  • text

Now results in


Class Comment {

    public function User(){
        return $this->belongsTo(User::class);
    }
}

But should be like


Class Comment {

    public function User(){
        return $this->belongsTo(User::class, 'created_by_id');
    }
}