Laravel 5 select with count query with group by exampleBy Hardik Savani | June 9, 2016 | | 3261 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"))
- Laravel 5 - Class 'Input' not found issue?
- How to implement infinite ajax scroll pagination in Laravel 5?
- How to confige Elasticsearch in our local system
- Select only one checkbox at a time using Jquery
- PHP AngularJS CRUD with Search and Pagination Example From Scratch
- How to use soft delete in Laravel 5?
- Bootstrap daterangepicker example code with demo using daterangepicker.js
- Dynamic Autocomplete search using Bootstrap Typeahead JS Example