Skip to content
Advertisement

Laravel 9 Array Filter

I have this array cart_items and works fine when mapped for database storage as in the code.

JavaScript
JavaScript

I need to filter the array using Arr:where(), where the product shop_id is a specific value.

I tried using an if function but the code just looped returing true where the shop_id was present.

JavaScript

I need to filter the array where the product shop_id is a specific value.

Advertisement

Answer

I know that this solution is not desirable. It would be too simplistic. You want to do it with Laravel 9 components. I’ll show you anyway:

JavaScript

Complete example: https://3v4l.org/19gnD

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