I have a form with two select and two date fields, when I click on the button it makes me a query with the value of the two select and "whereBetween" between the dates, is there any way of doing that I only consult according to the select in those who have entered a value?
I have edited the question and added the controller code.
public function results(Request $request)
{
$professionals = Professional::where('id', $request->input('professional_id'));
$resources = Resource::where('id', $request->input('resource_id'));
$fini = date("Y-m-d", strtotime($request->input('date_start')));
$ffin = date("Y-m-d", strtotime($request->input('date_end')));
$coordinations = Coordination::where('professional_id', $request->input('professional_id'))->where('resource_id', $request->input('resource_id'))->whereBetween('date', [$fini, $ffin])->get();
return view('coordinations.results')->with(compact('coordinations', 'professionals', 'resources'));
}