Hello Friends 👋,

Welcome To Infinitbility! ❤️

Many devs use count() method to check record exist or not in table and some are use get() method but laravel provide exist() and doesntExist() method to check record exist or not.

This article provide example to use exist() and doesntExist() method in laravel

let’s start today topic Laravel exist and doesntExist query Example or how to check record exist or not in laravel.

Instead of using the count method to determine if any records exist that match your query’s constraints, you may use the exists and doesntExist methods:


if (DB::table('orders')->where('finalized', 1)->exists()) {
    // ...
}

if (DB::table('orders')->where('finalized', 1)->doesntExist()) {
    // ...
}

Thanks For Reading…