How to create javascript function in laravel foreach loop

I need some help about this code I have some code in blade view @foreach($cart as $ct) <button type=”button” id=”edit” class=”btn-btn-delete”> <i class=”mr-1 fas fa-edit”></i>Edit </button> //when I at this point, it return id of current product <div class=”form-popup” id=”myForm”> //however, when I at this point, it return id of the last product <form action=””…

like and unlike with javascript and Laravel

I’m trying to implement a functionality where user can like and unlike product using javascript I followed this Laravel – Favourite / Un-Favourite button but it doesn’t work for me, the button can’t be clicked, any idea on how I can fix this? Routes Route::get(‘product/like/{id}’, [‘as’ => ‘product.like’, ‘uses’ => ‘LikeController@likeProduct’]); Route::get(‘product/{product}/unlike’,’LikeController@destroy’)->name(‘product.unlike’); Javascript <script> function…