mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
Update holidays-ical.blade.php
*Past events are removed. *Events that started earlier but are still ongoing today remain visible. *Anything from today onward displays.
This commit is contained in:
parent
f1a9103f0d
commit
ba08a0e7d8
1 changed files with 20 additions and 10 deletions
|
|
@ -2,36 +2,46 @@
|
||||||
@php
|
@php
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
$today = Carbon::today(config('app.timezone'));
|
||||||
|
|
||||||
$events = collect($data['ical'] ?? [])
|
$events = collect($data['ical'] ?? [])
|
||||||
->map(function (array $event): array {
|
->map(function (array $event): array {
|
||||||
$start = null;
|
|
||||||
$end = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$start = isset($event['DTSTART']) ? Carbon::parse($event['DTSTART'])->setTimezone(config('app.timezone')) : null;
|
$start = isset($event['DTSTART'])
|
||||||
|
? Carbon::parse($event['DTSTART'])->setTimezone(config('app.timezone'))
|
||||||
|
: null;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$start = null;
|
$start = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$end = isset($event['DTEND']) ? Carbon::parse($event['DTEND'])->setTimezone(config('app.timezone')) : null;
|
$end = isset($event['DTEND'])
|
||||||
|
? Carbon::parse($event['DTEND'])->setTimezone(config('app.timezone'))
|
||||||
|
: null;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$end = null;
|
$end = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'summary' => $event['SUMMARY'] ?? 'Untitled event',
|
'summary' => $event['SUMMARY'] ?? 'Untitled event',
|
||||||
'location' => $event['LOCATION'] ?? null,
|
'location' => $event['LOCATION'] ?? '—',
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'end' => $end,
|
'end' => $end,
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
->filter(fn ($event) => $event['start'])
|
->filter(fn ($event) =>
|
||||||
|
$event['start'] &&
|
||||||
|
(
|
||||||
|
$event['start']->greaterThanOrEqualTo($today) ||
|
||||||
|
($event['end'] && $event['end']->greaterThanOrEqualTo($today))
|
||||||
|
)
|
||||||
|
)
|
||||||
->sortBy('start')
|
->sortBy('start')
|
||||||
->take($size === 'quadrant' ? 5 : 8)
|
->take($size === 'quadrant' ? 5 : 8)
|
||||||
->values();
|
->values();
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|
||||||
<x-trmnl::view size="{{$size}}">
|
<x-trmnl::view size="{{$size}}">
|
||||||
<x-trmnl::layout class="layout--col gap--small">
|
<x-trmnl::layout class="layout--col gap--small">
|
||||||
<x-trmnl::table>
|
<x-trmnl::table>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue