alexis-riot
te
use Carbon\Carbon;
$project = Project::find(1);
$test = $project->users->sum(function ($user) {
$start = new Carbon($user->pivot->date_from);
$end = new Carbon($user->pivot->date_to);
return $start->diffInHoursFiltered(function (Carbon $date) {
return ($date->hour <= 18 && $date->hour >= 8);
}, $end);
});
[!] Aliasing 'Project' to 'App\Models\Project' for this Tinker session.
=> 34