diff --git a/migrations/Version20240802130923.txt b/migrations/Version20240802130923.txt
index 4de748337..e10e504ed 100644
--- a/migrations/Version20240802130923.txt
+++ b/migrations/Version20240802130923.txt
@@ -44,7 +44,6 @@ final class Version20240802130923 extends AbstractMigration
$this->addSql('ALTER TABLE profile_role ADD CONSTRAINT FK_E1A105FED60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE transaction ADD CONSTRAINT FK_723705D18157AA0F FOREIGN KEY (profile) REFERENCES profile (id)');
$this->addSql('ALTER TABLE session CHANGE sess_data sess_data LONGBLOB NOT NULL');
- $this->addSql('ALTER TABLE session RENAME INDEX session_sess_lifetime_idx TO sess_lifetime_idx');
}
public function down(Schema $schema): void
@@ -56,7 +55,6 @@ final class Version20240802130923 extends AbstractMigration
$this->addSql('ALTER TABLE participant_dish DROP FOREIGN KEY FK_41C99E869D1C3019');
$this->addSql('ALTER TABLE participant_dish DROP FOREIGN KEY FK_41C99E86148EB0CB');
$this->addSql('ALTER TABLE session CHANGE sess_data sess_data BLOB NOT NULL');
- $this->addSql('ALTER TABLE session RENAME INDEX sess_lifetime_idx TO session_sess_lifetime_idx');
$this->addSql('ALTER TABLE profile_role DROP FOREIGN KEY FK_E1A105FECCFA12B8');
$this->addSql('ALTER TABLE profile_role DROP FOREIGN KEY FK_E1A105FED60322AC');
$this->addSql('ALTER TABLE guest_invitation DROP FOREIGN KEY FK_CC0531331FB8D185');
diff --git a/migrations/Version20240904104901.php b/migrations/Version20240904104901.php
index 08447a77e..27c063cbc 100644
--- a/migrations/Version20240904104901.php
+++ b/migrations/Version20240904104901.php
@@ -46,7 +46,6 @@ public function up(Schema $schema): void
$this->addSql('ALTER TABLE profile_role ADD CONSTRAINT FK_E1A105FED60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE transaction ADD CONSTRAINT FK_723705D18157AA0F FOREIGN KEY (profile) REFERENCES profile (id)');
$this->addSql('ALTER TABLE session CHANGE sess_data sess_data LONGBLOB NOT NULL');
- $this->addSql('ALTER TABLE session RENAME INDEX session_sess_lifetime_idx TO sess_lifetime_idx');
}
public function down(Schema $schema): void
@@ -58,7 +57,6 @@ public function down(Schema $schema): void
$this->addSql('ALTER TABLE participant_dish DROP FOREIGN KEY FK_41C99E869D1C3019');
$this->addSql('ALTER TABLE participant_dish DROP FOREIGN KEY FK_41C99E86148EB0CB');
$this->addSql('ALTER TABLE session CHANGE sess_data sess_data BLOB NOT NULL');
- $this->addSql('ALTER TABLE session RENAME INDEX sess_lifetime_idx TO session_sess_lifetime_idx');
$this->addSql('ALTER TABLE profile_role DROP FOREIGN KEY FK_E1A105FECCFA12B8');
$this->addSql('ALTER TABLE profile_role DROP FOREIGN KEY FK_E1A105FED60322AC');
$this->addSql('ALTER TABLE guest_invitation DROP FOREIGN KEY FK_CC0531331FB8D185');
diff --git a/migrations/Version20240904132158.php b/migrations/Version20240904132158.php
index ec1bda831..6ed0d53c9 100644
--- a/migrations/Version20240904132158.php
+++ b/migrations/Version20240904132158.php
@@ -21,13 +21,11 @@ public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE guest_invitation CHANGE eventParticipation eventParticipation INT DEFAULT NULL');
- $this->addSql('ALTER TABLE session RENAME INDEX session_sess_lifetime_idx TO sess_lifetime_idx');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE session RENAME INDEX sess_lifetime_idx TO session_sess_lifetime_idx');
- $this->addSql('ALTER TABLE guest_invitation CHANGE eventParticipation eventParticipation INT NOT NULL');
}
}
diff --git a/migrations/Version20240905081818.php b/migrations/Version20240905081818.php
new file mode 100644
index 000000000..8d7d2b057
--- /dev/null
+++ b/migrations/Version20240905081818.php
@@ -0,0 +1,31 @@
+addSql('ALTER TABLE guest_invitation CHANGE eventParticipation eventParticipation INT DEFAULT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('ALTER TABLE guest_invitation CHANGE eventParticipation eventParticipation INT NOT NULL');
+ }
+}
diff --git a/src/Mealz/MealBundle/Controller/MealGuestController.php b/src/Mealz/MealBundle/Controller/MealGuestController.php
index c4b387467..83fc2332b 100644
--- a/src/Mealz/MealBundle/Controller/MealGuestController.php
+++ b/src/Mealz/MealBundle/Controller/MealGuestController.php
@@ -63,14 +63,14 @@ public function newGuestInvitation(
#[MapEntity(id: 'dayId')]
Day $mealDay,
GuestInvitationRepositoryInterface $guestInvitationRepo,
- EventParticipation $eventParticipation,
): JsonResponse {
+
$userProfile = $this->getProfile();
if (null === $userProfile) {
return new JsonResponse(null, Response::HTTP_FORBIDDEN);
}
- $guestInvitation = $guestInvitationRepo->findOrCreateInvitation($userProfile, $mealDay, $eventParticipation);
+ $guestInvitation = $guestInvitationRepo->findOrCreateInvitation($userProfile, $mealDay);
return new JsonResponse(['url' => $this->generateInvitationUrl($guestInvitation)], Response::HTTP_OK);
}
@@ -79,6 +79,7 @@ public function newGuestInvitation(
public function newGuestEventInvitation(
Day $dayId,
GuestInvitationRepositoryInterface $guestInvitationRepo,
+ #[MapEntity(id: 'eventId')]
EventParticipation $eventParticipation,
): JsonResponse {
$userProfile = $this->getProfile();
diff --git a/src/Mealz/MealBundle/Repository/GuestInvitationRepository.php b/src/Mealz/MealBundle/Repository/GuestInvitationRepository.php
index d5c48706b..b62227685 100644
--- a/src/Mealz/MealBundle/Repository/GuestInvitationRepository.php
+++ b/src/Mealz/MealBundle/Repository/GuestInvitationRepository.php
@@ -24,12 +24,16 @@ class GuestInvitationRepository extends BaseRepository implements GuestInvitatio
*/
public function findOrCreateInvitation(Profile $host, Day $day, ?EventParticipation $eventParticipation): GuestInvitation
{
- $invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId(), 'eventParticipation' => $eventParticipation]);
+ $entityManager = $this->getEntityManager();
+ $eventParticipation?
+ $invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId(), 'eventParticipation' => $eventParticipation->getId()])
+ :
+ $invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId()]);
+ $entityManager->persist($eventParticipation);
+ $entityManager->persist($day);
if (($invitation instanceof GuestInvitation) === false) {
- $invitation = new GuestInvitation($host, $day);
-
- $entityManager = $this->getEntityManager();
+ $invitation = new GuestInvitation($host, $day,$eventParticipation);
$entityManager->persist($invitation);
$entityManager->flush();
}
diff --git a/src/Resources/src/api/getEventGuestLink.ts b/src/Resources/src/api/getEventGuestLink.ts
index b60aa107f..08ed23a5e 100644
--- a/src/Resources/src/api/getEventGuestLink.ts
+++ b/src/Resources/src/api/getEventGuestLink.ts
@@ -6,7 +6,7 @@ export default async function getEventGuestLink(eventParticipation?: EventPartic
console.log('eventParticipation im getEventGuestLink:\n '+ JSON.stringify(eventParticipation));
// hier kommt undefined beim eventParticipation?.day.date rein
console.log('DayId:\n '+ JSON.stringify(eventParticipation?.day.dayId));
- const { error, response: link, request } = useApi('GET', `/event/invitation/${eventParticipation?.day.dayId}/${eventParticipation?.eventId}`);
+ const { error, response: link, request } = useApi('GET', `/event/invitation/${eventParticipation?.day.dayId}/${eventParticipation?.participationId}`);
await request();