0

I have one question, maybe it's really stupid, sorry. For example, I have "Users" table and I need to perform some action with each user (not with all users so I can't use bulk update. Just imagine this situation).

Is there any difference between:

$users = Users::all();
foreach ($users as $user) {
    //some action
}

and

foreach (Users::all() as $user) {
        //some action
}

Appreciate any explanation.

Andrey P.
  • 139
  • 2
  • 14

1 Answers1

1

It really depends on your situation. Personally I find readability the key. Using 'one use' variables is mostly more readable.

jjj
  • 187
  • 1
  • 9