Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

christophrumpel/larastreamers

238 stars
1 code files
View christophrumpel/larastreamers on GitHub

app/Actions/PrepareStreams.php

Open in GitHub
class PrepareStreams
{
public function handle(Collection $streams): Collection
{
return $streams
->sortBy('scheduled_start_time', null, $this->isDescending)
->groupBy(static fn(Stream $item): string => $item->scheduled_start_time->format('D d.m.Y'))
->mapWithKeys(static function(Collection $item, string $date): array {
$dateObject = Carbon::createFromFormat('D d.m.Y', $date);
 
if ($dateObject->isYesterday()) {
$date = 'Yesterday';
}
 
if ($dateObject->isToday()) {
$date = 'Today';
}
 
if ($dateObject->isTomorrow()) {
$date = 'Tomorrow';
}
 
return [$date => $item];
});
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.