Laravel pagintion with fixed columns is not returning relationship data

  eloquent, eloquent--relationship, laravel

I have simple hasOne relationship and fixed list of displayed columns.
If to put columns on paginate method, outputed relation data will be null.

    $model->with(['item:id,title'])->paginate(5); // item filled correctly 
    $model->with(['item:id,title'])->paginate(5, ['id','name']); // item will be null

How to make it work together?

Source: Laravel

Leave a Reply