Laravel 5 select with count query with group by exampleBy Hardik Savani | June 9, 2016 | | 12565 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 ckeditor value with tags on ajax-submit ?
- Laravel 5 - Implement Flash Messages with example
- Laravel 5 - whereIn and whereNotIn with subquery example using query builder
- Laravel 5 Repository Pattern Tutorial from scratch
- Laravel 5.2 multi auth example using Auth guard from scratch
- How to solve 'There are no commands defined in the "cashier" namespace' in Laravel 5
- How to add pagination with union in Laravel 4 and Laravel 5 ?
- How to get ip address using php code?