Change your form to a GET action on the show page.
Not sure what you might search for in the show?
The property ID can be the same as part of the URL and the start and end date will be passed as querystring
Make sure you accept Request into the controller.
public function show(Property $property, Request, $request)
{
if($request->has('start_date') {
// performing a search against the injected $property
// return view with results
} else {
// regular show
}
Your $property is already loaded, so you don't need to do it twice
Change this
$property = Property::with('propertycalendars')->where('id', $property->id)->first();
to
$property->load('propertycalendars');
and save a query
What does this do:
foreach ($property->propertycalendars as $prop) {
$end_reserve = $prop->reserve_end;
}
if its just to end up with the last value;
$end_reserve = $property->propertycalendars->last()->reserve_end;
what does this do;
$pdate = Property::with('dates')->get();
gets ALL properties with their dates? Will this be manageable as your application grows?
Might be an idea to install Laravel Debugbar then you can review all queries to see if they make sense.