Laravel 5 select with count query with group by exampleBy Hardik Savani | June 9, 2016 | | 56067 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 integrate paypal payment gateway with laravel 5.4
- How to remove # from URL in AngularJS?
- PHP Script - Login with Facebook using facebook-php-sdk and MySQL example with demo
- How to create custom facade in laravel 5.2?
- How to execute artisan commands from route or controller in Laravel ?
- Bootstrap multiselect dropdown in popup using popupMultiSelect plugin
- PHP MySQL - Simple Image Gallery CRUD example from scratch
- Automatically Refresh or Reload a Page using jQuery Example