diff --git a/web_app/src/Entity/Purchase.php b/web_app/src/Entity/Purchase.php index 14a31b97063e1a81883cc352f12825d7f9ff2124..e16508199f956ce8dffcedc6622c6d16dcb364dd 100644 --- a/web_app/src/Entity/Purchase.php +++ b/web_app/src/Entity/Purchase.php @@ -14,12 +14,18 @@ class Purchase private ?int $id = null; #[ORM\Column] + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: false)] private ?int $user_id = null; #[ORM\Column] + #[ORM\ManyToOne(targetEntity: Wishlist::class)] + #[ORM\JoinColumn(nullable: false)] private ?int $wishlist_id = null; #[ORM\Column] + #[ORM\ManyToOne(targetEntity: Item::class)] + #[ORM\JoinColumn(nullable: false)] private ?int $item_id = null; #[ORM\Column(length: 255, nullable: true)] diff --git a/web_app/src/Entity/User.php b/web_app/src/Entity/User.php index f3427bebf582d0ffd4690107e593defea5dae0e2..3c6a72d9165efcdaf4726b9fdbe9603ab1700e2b 100644 --- a/web_app/src/Entity/User.php +++ b/web_app/src/Entity/User.php @@ -23,7 +23,7 @@ class User #[ORM\Column(length: 255, nullable: true)] private ?string $surname = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, unique: true)] private ?string $email = null; #[ORM\Column(length: 255)] diff --git a/web_app/src/Entity/WishList.php b/web_app/src/Entity/WishList.php index 3ed0aa80ce31445afe0e85e25c3b62dfcfec2837..acbb88b269f95c9e7f5203fc2643f1152f112e8b 100644 --- a/web_app/src/Entity/WishList.php +++ b/web_app/src/Entity/WishList.php @@ -14,7 +14,8 @@ class WishList #[ORM\Column] private ?int $id = null; - #[ORM\Column] + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: false)] private ?int $user_id = null; #[ORM\Column(length: 255)] diff --git a/web_app/src/Entity/WishListItem.php b/web_app/src/Entity/WishListItem.php index e83f9d9f545d4270ac9680f453b76234b1a9a662..93fb8c6d5a2d45fd3923f0187a57c1384e03bffa 100644 --- a/web_app/src/Entity/WishListItem.php +++ b/web_app/src/Entity/WishListItem.php @@ -14,9 +14,13 @@ class WishListItem private ?int $id = null; #[ORM\Column] + #[ORM\ManyToOne(targetEntity: Wishlist::class)] + #[ORM\JoinColumn(nullable: false)] private ?int $wishlist_id = null; #[ORM\Column] + #[ORM\ManyToOne(targetEntity: Item::class)] + #[ORM\JoinColumn(nullable: false)] private ?int $item_id = null; public function getId(): ?int diff --git a/web_app/src/Entity/WishListMember.php b/web_app/src/Entity/WishListMember.php index ee4e53f34ec1e8b45430403b4cb8ef9dc0c5ae18..ab749ccb495236ae32341ebc71ded994bfbb48f7 100644 --- a/web_app/src/Entity/WishListMember.php +++ b/web_app/src/Entity/WishListMember.php @@ -14,9 +14,13 @@ class WishListMember private ?int $id = null; #[ORM\Column] + #[ORM\ManyToOne(targetEntity: Wishlist::class)] + #[ORM\JoinColumn(nullable: false)] private ?int $wishlist_id = null; #[ORM\Column] + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: false)] private ?int $user_id = null; #[ORM\Column] @@ -92,4 +96,11 @@ class WishListMember return $this; } + + public function setId(?Wishlist $id): static + { + $this->id = $id; + + return $this; + } }