Compare commits

...

2 Commits

Author SHA1 Message Date
philipp lang d452f05beb Add page meta for later registration
continuous-integration/drone/push Build is passing Details
2025-07-26 01:31:42 +02:00
philipp lang f044aab67c Add start to breadcrumb 2025-07-26 00:57:20 +02:00
3 changed files with 21 additions and 3 deletions

@ -1 +1 @@
Subproject commit a6ca0d2a6ce9f9626b8e3c80d916fe8a6f793dfd
Subproject commit e4fa326f3593fc61573bd81bfdfe75a3d4711124

View File

@ -8,6 +8,7 @@ use Cms\Classes\Page;
use Silva\Adrema\Exceptions\ComponentException;
use Silva\Adrema\Models\Settings;
use Silva\Adrema\Support\FetchAllEvents;
use Validator;
abstract class EventManager extends ComponentBase
{
@ -15,6 +16,7 @@ abstract class EventManager extends ComponentBase
public array $settings = [];
public ?array $event = null;
public array $eventMeta = [];
public array $pageMeta = [];
/** @var Collection<int, mixed> */
public Collection $events;
@ -37,17 +39,31 @@ abstract class EventManager extends ComponentBase
$this->loadColors();
$this->loadSettings();
$this->loadSingleEvent();
$this->loadQueryParams();
$this->page['breadcrumbs'] = $this->getBreadcrumbs();
}
private function loadQueryParams(): array {
$validator = Validator::make(array_only(request()->query(), ['signature', 'id', 'later']), [
'signature' => 'required|string',
'id' => 'required|string|uuid:4',
'later' => 'required|numeric|in:1',
]);
return $validator->fails()
? ['later' => '0']
: $validator->validated();
}
private function getBreadcrumbs(): Collection
{
$breadcrumbs = collect([]);
$breadcrumbs->push(['url' => '/', 'title' => 'Start', 'isActive' => false]);
$breadcrumbs->push(['url' => $this->settings['indexUrl'], 'title' => 'Veranstaltungen', 'isActive' => $this->event === null]);
if ($this->event) {
$breadcrumbs->push([
'url' => (string) str($this->settings['singleUrl'])->replace(':slug', $this->event['slug']),
'url' => str($this->settings['singleUrl'])->replace(':slug', $this->event['slug'])->toString(),
'title' => $this->event['name'],
'isActive' => !$this->isRegistering()
]);
@ -55,7 +71,7 @@ abstract class EventManager extends ComponentBase
if ($this->event && $this->isRegistering()) {
$breadcrumbs->push([
'url' => (string) str($this->settings['registerUrl'])->replace(':slug', $this->event['slug']),
'url' => str($this->settings['registerUrl'])->replace(':slug', $this->event['slug'])->toString(),
'title' => 'Anmeldung',
'isActive' => true,
]);
@ -153,6 +169,7 @@ abstract class EventManager extends ComponentBase
$this->eventMeta = data_get($eventData, 'meta', []);
$this->events = $this->page['events'] = collect($eventData['data']);
$this->event = $this->page['event'] = $this->events->first(fn ($event) => $event['slug'] == $eventSlug);
$this->pageMeta = $this->loadQueryParams();
$this->currentUrl = url()->current();
}

View File

@ -10,6 +10,7 @@
<script type="text/javascript">
var adrema_event_config = {{__SELF__.event.config | json_encode | raw}};
var adrema_event_meta = {{__SELF__.eventMeta | json_encode | raw}};
var adrema_page_meta = {{__SELF__.pageMeta | json_encode | raw}};
</script>
{% endif %}