B
B
bacca2018-04-20 01:31:33
Laravel
bacca, 2018-04-20 01:31:33

How to fetch columns in a database while eager loading?

Good evening, please tell me how to select columns during "greedy loading"
control code:
5ad962f040d90385003313.png
Answer:
5ad962fc380f9106744967.png
I tried both select and addSeclect
with a normal query, everything is ok:
5ad963036efe3566912253.png
the answer is like this:
5ad9630b60942883509447.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
anlamas, 2018-04-20
@anlamas

// ты забыл id-шки
select('id', 'name');
// laravel >= 5.5
->with('user:id,title')

B
bacca, 2018-04-24
@bacca

Thanks, for some reason I thought that the select should be inserted into the query constructor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question