Below is the code example of how you can listen to the "DB" facade.
<?php use \DB; $count = 0; DB::listen(fn ($sql) => $count++); dd($count); // get the total count
Learn the way to get the total number of queries by listening to any query that was run on Laravel
Created on Aug 06, 2021
•731 views
<?php use \DB; $count = 0; DB::listen(fn ($sql) => $count++); dd($count); // get the total count
If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️
Load comments for How to Count The Number of Queries to the Database in Laravel
Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.
View Components1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago