I would like to execute the following sentence using laravel eloquent
SELECT *, count(*) FROM reserves group by day
The only solution for me is to create a view in the database, but I'm sure there is a way to do this with laravel.
You can use this:
$reserves = DB::table('reserves')->selectRaw('*, count(*)')->groupBy('day');
As you want to do this with Laravel Eloquent, I assume that you have the model name Reserve . In this case, you can use this
Reserve
$reserve = Reserve::all()->groupBy('day')->count();