|
|
@ -8,6 +8,7 @@ use Cms\Classes\Page;
|
|
|
|
use Silva\Adrema\Exceptions\ComponentException;
|
|
|
|
use Silva\Adrema\Exceptions\ComponentException;
|
|
|
|
use Silva\Adrema\Models\Settings;
|
|
|
|
use Silva\Adrema\Models\Settings;
|
|
|
|
use Silva\Adrema\Support\FetchAllEvents;
|
|
|
|
use Silva\Adrema\Support\FetchAllEvents;
|
|
|
|
|
|
|
|
use Validator;
|
|
|
|
|
|
|
|
|
|
|
|
abstract class EventManager extends ComponentBase
|
|
|
|
abstract class EventManager extends ComponentBase
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -15,6 +16,7 @@ abstract class EventManager extends ComponentBase
|
|
|
|
public array $settings = [];
|
|
|
|
public array $settings = [];
|
|
|
|
public ?array $event = null;
|
|
|
|
public ?array $event = null;
|
|
|
|
public array $eventMeta = [];
|
|
|
|
public array $eventMeta = [];
|
|
|
|
|
|
|
|
public array $pageMeta = [];
|
|
|
|
|
|
|
|
|
|
|
|
/** @var Collection<int, mixed> */
|
|
|
|
/** @var Collection<int, mixed> */
|
|
|
|
public Collection $events;
|
|
|
|
public Collection $events;
|
|
|
@ -37,17 +39,31 @@ abstract class EventManager extends ComponentBase
|
|
|
|
$this->loadColors();
|
|
|
|
$this->loadColors();
|
|
|
|
$this->loadSettings();
|
|
|
|
$this->loadSettings();
|
|
|
|
$this->loadSingleEvent();
|
|
|
|
$this->loadSingleEvent();
|
|
|
|
|
|
|
|
$this->loadQueryParams();
|
|
|
|
$this->page['breadcrumbs'] = $this->getBreadcrumbs();
|
|
|
|
$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
|
|
|
|
private function getBreadcrumbs(): Collection
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$breadcrumbs = collect([]);
|
|
|
|
$breadcrumbs = collect([]);
|
|
|
|
|
|
|
|
$breadcrumbs->push(['url' => '/', 'title' => 'Start', 'isActive' => false]);
|
|
|
|
$breadcrumbs->push(['url' => $this->settings['indexUrl'], 'title' => 'Veranstaltungen', 'isActive' => $this->event === null]);
|
|
|
|
$breadcrumbs->push(['url' => $this->settings['indexUrl'], 'title' => 'Veranstaltungen', 'isActive' => $this->event === null]);
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->event) {
|
|
|
|
if ($this->event) {
|
|
|
|
$breadcrumbs->push([
|
|
|
|
$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'],
|
|
|
|
'title' => $this->event['name'],
|
|
|
|
'isActive' => !$this->isRegistering()
|
|
|
|
'isActive' => !$this->isRegistering()
|
|
|
|
]);
|
|
|
|
]);
|
|
|
@ -55,7 +71,7 @@ abstract class EventManager extends ComponentBase
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->event && $this->isRegistering()) {
|
|
|
|
if ($this->event && $this->isRegistering()) {
|
|
|
|
$breadcrumbs->push([
|
|
|
|
$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',
|
|
|
|
'title' => 'Anmeldung',
|
|
|
|
'isActive' => true,
|
|
|
|
'isActive' => true,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
@ -153,6 +169,7 @@ abstract class EventManager extends ComponentBase
|
|
|
|
$this->eventMeta = data_get($eventData, 'meta', []);
|
|
|
|
$this->eventMeta = data_get($eventData, 'meta', []);
|
|
|
|
$this->events = $this->page['events'] = collect($eventData['data']);
|
|
|
|
$this->events = $this->page['events'] = collect($eventData['data']);
|
|
|
|
$this->event = $this->page['event'] = $this->events->first(fn ($event) => $event['slug'] == $eventSlug);
|
|
|
|
$this->event = $this->page['event'] = $this->events->first(fn ($event) => $event['slug'] == $eventSlug);
|
|
|
|
|
|
|
|
$this->pageMeta = $this->loadQueryParams();
|
|
|
|
$this->currentUrl = url()->current();
|
|
|
|
$this->currentUrl = url()->current();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|