How to check if an item exists in Laravel Eloquent collection without counting

Categorized as Laravel Tagged

Hello friends! You can check if an item exists or not using Laravel Eloquent with ease. It will return true or false depending on whether it does exist or no. Let’s see the code below:

Comment::where('comment','Hello world')->doesntExist();
Comment::where('comment','Hello world')->exists();

Leave a reply

Your email address will not be published. Required fields are marked *