is there a way to select only certain columns when doing eager-loading in laravel?
$columns = ['col_1', 'col_2', 'col_3'];
$model = MyModel::findOrFail(Input::get('id'), $columns);
$model->load('position');
In My model I Have defined:
public function position() {
return $this->belongsToMany('Position', 'mymodel_positions')->withTimestamps();
}
When I don't provide the $columns parameter like MyModel::findOrFail(id). Positions are loaded correctly. However if I do provide $columns, the positions ale always empty.
What I want: eagerly load a relation AND specify the columns (Not the ones in the loaded relation). I'm sure It's possible, but i simply don't get it...
Hope for your help.