$users collection sent to view is ordered by department.
I would like to alternate the color for each department on the list.
The example I have above is not working. The way it is written Laravel blade is not liking the variable assignment before @endforeach, I get the squiggly lined under $user.
What would be the correct approach for assigning $user->department to the variable above the @foreach loop?
Hmm..., I would like to alternate between red and blue only and there could be many different departments. In the loop I need to switch color every time the department is different.
Somehow the loop need to keep track what was the department for previous $user.
If I user the $loop->even that will alternate every <h1>
In the $user collection there could be first 7 user with one department, next 2 user with different and so on...
I wan the color to be different only if there is a different department.