-
Hello, I'm hoping that this is possible to do, I just have no idea how I would go about accomplishing it. I'm writing some code to test this and right now what I have is the following (again just for testing purposes): $employees = User::where('c', '=', 'US')->paginate();
foreach ($employees as $employee) {
echo $employee->getFirstAttribute('sn').' '.$employee->getFirstAttribute('givenName').' - '.$employee->getFirstAttribute('c');
echo '<br />------------------------------------------------------<br />';
} Based on another answer found in the issues section I believe, I found that you can do I like the select feature specifically because it reduces the amount of data you are getting, but I'm having trouble figuring out how I can combine the Leaving the below just for the history, but I realized the issue was my fault in my one if statement where I was checking for the givenName to be equal to blank, so of course I wasn't outputting anything. The above I am still unsure of though.
The way that code looked like was the following (since I'm guessing I did something wrong): User::where('c', '=', 'US')->chunk(1000, function ($employees) {
foreach ($employees as $employee) {
$username = $employee->getFirstAttribute('samaccountname');
if ($employee->getFirstAttribute('userAccountControl') == 512) {
if ($employee->getFirstAttribute('givenName') == '') {
echo $username.','.$employee->getFirstAttribute('givenName').','.$employee->getFirstAttribute('displayName').','.$employee->getFirstAttribute('countryCode').','.$employee->getFirstAttribute('whenChanged').'<br />';
}
}
}
}); If I change the
Appreciate any direction anyone can give me on how to actually accomplish this (again if it's possible). Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
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 above and they both got me the results I wanted. -Shark2k |
Beta Was this translation helpful? Give feedback.
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:
or
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…