Laravel 5 select with count query with group by exampleBy Hardik Savani | June 9, 2016 | | 20572 Viewer | Category : Laravel
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 Ip Address in Codeigniter?
- Jquery - Display a loading gif image before a image loads using Eager ImageLoader plugin
- How to set vertical align middle div by CSS in HTML?
- Dynamic Autocomplete search using Bootstrap Typeahead JS Example
- How to get user agent value in Laravel 5?
- How to add jquery modal popup in PHP?
- How to change app version code in Ionic framework
- Pixel tracking code php example