Skip to content

How to combine User::where and User::select #565

Answered by shark2k
shark2k asked this question in Q&A
Discussion options

You must be logged in to vote

Alright, so answering this myself as I ended up trying something (which I should've tried before opening this discussion, so my bad).

The answer was as simple as doing one of the following:

$employees = User::where('c', '=', 'US')->select(['samaccountname','sn','givenName'])->get();

or

$employees = User::select(['samaccountname','sn','givenName'])->where('c', '=', 'US')->get();

Not being super comfortable with OOP, I wasn't sure if they could be linked together (and for some reason initially had a some reservations about how exactly to do the "linking" because I couldn't get past how they were being called, though looking at get it should have been clear).

Anyway, decided to try both ways…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@stevebauman
Comment options

@shark2k
Comment options

@stevebauman
Comment options

Answer selected by shark2k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants