Change your model to specify what columns you want selected:
public function user() {
return $this->belongs_to('User')->select(array('id', 'username'));
}
And don’t forget to include the column you’re joining on.
More Related Contents:
- Laravel one to many relation with a one to one relation
- How to Create Multiple Where Clause Query Using Laravel Eloquent?
- How do I get the query builder to output its raw SQL query as a string?
- Get the Last Inserted Id Using Laravel Eloquent
- Bulk Insertion in Laravel using eloquent ORM
- Laravel Check If Related Model Exists
- Laravel, sync() – how to sync an array and also pass additional pivot fields?
- How to alias a table in Laravel Eloquent queries (or using Query Builder)?
- Laravel Model with Two Primary Keys update [duplicate]
- Laravel eager loading with limit
- Laravel OrderBy relationship count
- Laravel 5.2 – Use a String as a Custom Primary Key for Eloquent Table becomes 0
- Laravel Eloquent: How to order results of related models?
- Laravel 4: how to “order by” using Eloquent ORM [duplicate]
- How to set a default attribute value for a Laravel / Eloquent model?
- Laravel $q->where() between dates
- Laravel – Database, Table and Column Naming Conventions?
- Order By before Group By using Eloquent (Laravel)
- How to Make Laravel Eloquent “IN” Query?
- How to Merge Two Eloquent Collections?
- Update without touching timestamps (Laravel)
- laravel collection to array
- Difference between Eloquent\Model::get() and all()
- Laravel Eloquent sort by relation table column
- Eloquent Parent-Child relationship on same model
- Laravel 4.1: How to paginate eloquent eager relationship?
- How can I query raw via Eloquent?
- A __construct on an Eloquent Laravel Model
- Eloquent groupBy make “SQLSTATE[42000]” with valid SQL query in Laravel 5.3
- Laravel Eloquent update just if changes have been made