Closed xYvanB closed 1 year ago
Shouldn't the model's function be prefixed with scope
to be able to use the model's local scope. So renaming to scopeFrameDepartureDate
would allow you to do the following in your filter:
// assuming the $startDate and $endDate are found in the input as `start_date` and `end_date`
public function frameDepartureDate($dateType)
{
switch ($dateType) {
case 1: //departure date
$formattedStartDate = Carbon::createFromFormat('d/m/Y', $this->input('start_date'));
$formattedEndDate = Carbon::createFromFormat('d/m/Y', $this->input('end_date'));
return $this->frameDepartureDate($formattedStartDate, $formattedEndDate);
}
}
In my trainsTrip model i've declared the following function
on my trainsTripFramesFilter
what I would like to do is to filter in the table "train trips" for the column full_departure_date with a range of dates but I can't get the function to execute in any way. Unfortunately, the Scope is not for me as I need to be able to run the filter all the time and not just in the presence of other.