Skip to content
Advertisement

laravel id value changed after adding a nested loop

I used the following code to display the role of the user however, when I want to edit or delete it leads me to the deleted ids number 2/3 it return the same thing even when I change the for else with foreach Attempt to read property "id" on null (View: C:laravelgautoresourcesviewsdashboarduseredit.blade.php)! when I delete the nested foreach loop everything back to normal thank you in advance

JavaScript

Advertisement

Answer

Your users are also saved in $item and in the loop you are allocating $item a different value every time.

Try changing the code to

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement