Is there a way to select only specific columns when using "with" with eloquent?
My problem is that i am getting a very long list of accounts and i also need to get their websites using the relation "with", but the "websites" object is big and it makes the request very slow.
I tried using:
$accounts = $accounts->with('websites')->select(['account_id','url']); And also:
$accounts = $accounts->with('websites', function($query) { $query->select(['account_id','url']); }); And they both didn't work.
I didn't see an answer for this in their documentation, so if there is a way i would really appreciate if someone would share it with me. Also if there is an alternative for "with" that can give the same result it will be great as well. Thanks.