Laravel utilise la variable intérieure de la fonction de rappel

// You should use the "use" keyword to use a variable in the anonymous scope
$current_date = '2021-01-14';
$schedules = Schedule::all();

// Here's an example of filtering a collection using a variable defined
// outside the anonymous scope. Here we used $current_date within the callback
// function to keep only the schedules with the same date as the current date
$filtered = $schedules->filter(function ($schedule) use ($current_date) {
        return $schedule->date == $current_date;
};
Yingfufu