From e9aa66a86026796761d4770d3faef2b9d520a24c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20G=C3=BCnther?=
Date: Sun, 21 Jun 2026 00:35:25 +0200
Subject: [PATCH] Direct liunk to current event in mobile mode
---
app/Providers/GlobalDataProvider.php | 62 +++++++++++++++++----------
app/Repositories/EventRepository.php | 12 ++++++
resources/js/layouts/AppLayout.vue | 63 ++++++++++++++++++++++++----
3 files changed, 107 insertions(+), 30 deletions(-)
diff --git a/app/Providers/GlobalDataProvider.php b/app/Providers/GlobalDataProvider.php
index 5fae3ad..bfb3bfa 100644
--- a/app/Providers/GlobalDataProvider.php
+++ b/app/Providers/GlobalDataProvider.php
@@ -26,28 +26,7 @@ class GlobalDataProvider {
'tenant' => app('tenant'),
'activeUsers' => $this->getActiveUsers(),
'version' => config('app.version'),
- ]);
- }
-
- public function getAllInvoiceTypes() : JsonResponse {
- $invoiceTypes = [];
- foreach (InvoiceType::orderBy('sort_order')->get() as $invoiceType) {
- if (
- $invoiceType->slug === InvoiceType::INVOICE_TYPE_OTHER
- ) {
- continue;
- }
-
- $invoiceTypes[] = [
- 'slug' => $invoiceType->slug,
- 'name' => $invoiceType->name
- ];
- }
-
- $invoiceTypes[] = ['slug' => InvoiceType::INVOICE_TYPE_OTHER, 'name' => 'Sonstige Kosten'];
-
- return response()->json([
- 'invoiceTypes' => $invoiceTypes
+ 'currentEvent' => $this->getCurrentEventData(),
]);
}
@@ -99,10 +78,47 @@ class GlobalDataProvider {
]);
}
+ private function getCurrentEventData() : ?array {
+ if (null === $this->user) {
+ return null;
+ }
+
+ $currentEvent = new EventRepository()->getMyCurrentEvent();
+ if (null === $currentEvent) {
+ return null;
+ }
+
+ return [
+ 'identifier' => $currentEvent->identifier,
+ 'name' => $currentEvent->name,
+ ];
+ }
+
+ public function getAllInvoiceTypes() : JsonResponse {
+ $invoiceTypes = [];
+ foreach (InvoiceType::orderBy('sort_order')->get() as $invoiceType) {
+ if (
+ $invoiceType->slug === InvoiceType::INVOICE_TYPE_OTHER
+ ) {
+ continue;
+ }
+
+ $invoiceTypes[] = [
+ 'slug' => $invoiceType->slug,
+ 'name' => $invoiceType->name
+ ];
+ }
+
+ $invoiceTypes[] = ['slug' => InvoiceType::INVOICE_TYPE_OTHER, 'name' => 'Sonstige Kosten'];
+
+ return response()->json([
+ 'invoiceTypes' => $invoiceTypes
+ ]);
+ }
+
private function generateNavbar() : array {
$eventRepository = new EventRepository();
-
$navigation = [
'personal' => [],
'common' => [],
diff --git a/app/Repositories/EventRepository.php b/app/Repositories/EventRepository.php
index 3f0c14b..b4eafef 100644
--- a/app/Repositories/EventRepository.php
+++ b/app/Repositories/EventRepository.php
@@ -20,6 +20,18 @@ class EventRepository {
}
+ public function getMyCurrentEvent() : ?Event {
+ $events = $this->getEventsByCriteria([
+ ['archived', '=', false],
+ ['start_date', '<=', now()],
+ ['end_date', '>=', now()],
+ ], true);
+ if (count($events) !== 1) {
+ return null;
+ }
+ return $events[0];
+ }
+
public function getUpcoming(int $maxCount = 5, bool $accessCheck = true) : array {
$events = [];
foreach ( $this->getEventsByCriteria([
diff --git a/resources/js/layouts/AppLayout.vue b/resources/js/layouts/AppLayout.vue
index f8c1aa4..068f274 100644
--- a/resources/js/layouts/AppLayout.vue
+++ b/resources/js/layouts/AppLayout.vue
@@ -1,5 +1,5 @@