Laravel 5 select with count query with group by exampleBy Hardik Savani | June 9, 2016 | | 4240 Viewer | Category : Laravel
Share this post:
We always required to get count of number of records or number of inserted record of current month etc in laravel. We can use mysql count function in laravel eloquent. We have two way to get count of column value. first we can use laravel count() of query builder and another one we can use with directly with select statement using DB::raw(). I give you both example you can see and use any one as perfect for you.
$data = DB::table("click")->count();
$data = DB::table("click")
->select(DB::raw("COUNT(*) as count_row"))
- How to get last inserted id in laravel 5?
- Laravel 5 export to pdf using maatwebsite example
- Laravel 5 File(Image) Upload Example with Validation
- Laravel 5 - Implement Flash Messages with example
- Laravel 5 - Full Text Search Example using Scout and Algolia Packages
- How to check uploaded file is empty or not in Laravel 5.3?
- How to send mail using mailable in laravel 5.3?
- Codeigniter 3 - CRUD(Create, Read, Update and Delete) using JQuery Ajax, Bootstrap, Models and MySQL