Skip to content
Advertisement

How to get instance of a collection in Laravel 8 to use in a if statement?

How to get instance of a collection in Laravel 8?

I want to make a if statement if $event->like (CODE BELOW) does not exists for that specific event and an else statement I want to execute the below 2nd foreach.

Controller

JavaScript

View

JavaScript

Advertisement

Answer

if I understand you correctly you will need to check for the likes count if there are likes so iterate throw it like this

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