I have table called "orders" suppose that i have two columns [date, total_price], in my case i need to filter data by date, i am already filter data but i need to get all orders that created in the same date in one row and with the total price
example:
if i have 3 order
first order date=> 16-10-2022, total price=>50
second order date=> 16-10-2022, total price=>100
third order date=> 16-10-2022, total price=>150
fourth order date=> 20-10-2022, total price=>90
i need data like that
date=> 16-10-2022, total price=>50+100+150
//in your controller like:
public function search_date(Request $request){
$date = Record::where('date', $request->search)->get()->sum('price');
return view('view')->with(['data'=>$date]);
}
//in your view like:
@forelse ($data as $record)
//gives the total price of the filtered date
{{$record->price}}
@empty
<p>No order Found</p>
@endforelse