Laravel 5 select with count query with group by exampleBy Hardik Savani | June 9, 2016 | | 7098 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 import export to excel and csv using maatwebsite example.
- Laravel Jquery Ajax Pagination Example From Scratch
- How to add Delete cascade to existing column in Laravel 5, without remove column?
- Laravel 5 - Implementing datatables tutorial using yajra package
- How to create and check custom header with middleware for REST API in Laravel 5 ?
- Laravel 5 export to pdf using maatwebsite example
- How to add text on image in laravel 5?