Laravel 5 select with count query with group by exampleBy Hardik Savani | June 9, 2016 | | 29171 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"))
- Install Sublime Text 3 in Ubuntu 14.04 using Terminal
- Laravel ajax render view with data example
- Laravel 5 File(Image) Upload Example with Validation
- How to generate UUID in Laravel 5 ?
- AngularJS - How to create read more/less toggle using Directive?
- Example of Cron Job in Laravel 5
- Laravel 5 - How to implement gravatar image using thomaswelton/laravel-gravatar package
- Laravel 5.3 - How to create SEO friendly sluggable URL