diff --git a/README.md b/README.md index 80897c030a514d5ea6c3020ca6a98c991c9a5c3a..1599af0ade21ead39ecd2a66ac9d2c3294009680 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ Create an entity ``` docker exec -it symfony_app php bin/console make:entity ``` +Update getters and setters in new properties where added manually +``` +docker exec -it symfony_app php bin/console make:entity --regenerate +``` Create migration file to apply in the dp ``` diff --git a/web_app/migrations/Version20250223144640.php b/web_app/migrations/Version20250223154313.php similarity index 59% rename from web_app/migrations/Version20250223144640.php rename to web_app/migrations/Version20250223154313.php index a3abef2073b2dba6efe635c8eed558927dcd89ef..67db709348926c8e9402f4b13edc4d19031bb0f9 100644 --- a/web_app/migrations/Version20250223144640.php +++ b/web_app/migrations/Version20250223154313.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20250223144640 extends AbstractMigration +final class Version20250223154313 extends AbstractMigration { public function getDescription(): string { @@ -21,16 +21,18 @@ final class Version20250223144640 extends AbstractMigration { // this up() migration is auto-generated, please modify it to your needs $this->addSql('CREATE TABLE item (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, price DOUBLE PRECISION NOT NULL, purchase_url VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE purchase (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, wishlist_id INT NOT NULL, item_id INT NOT NULL, url_proof VARCHAR(255) DEFAULT NULL, message VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, user_name VARCHAR(255) DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, surname VARCHAR(255) DEFAULT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, is_blocked TINYINT(1) DEFAULT NULL, role VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE wish_list (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, name VARCHAR(255) NOT NULL, expiration_date DATETIME DEFAULT NULL, is_active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE wish_list_item (id INT AUTO_INCREMENT NOT NULL, wishlist_id INT NOT NULL, item_id INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE wish_list_member (id INT AUTO_INCREMENT NOT NULL, wishlist_id INT NOT NULL, user_id INT NOT NULL, can_edit TINYINT(1) NOT NULL, is_accepted TINYINT(1) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE purchase (id INT AUTO_INCREMENT NOT NULL, user INT NOT NULL, wishlist INT NOT NULL, item INT NOT NULL, url_proof VARCHAR(255) DEFAULT NULL, message VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, user_name VARCHAR(255) DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, surname VARCHAR(255) DEFAULT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, is_blocked TINYINT(1) DEFAULT NULL, role VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE wish_list (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, name VARCHAR(255) NOT NULL, expiration_date DATETIME DEFAULT NULL, is_active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_5B8739BDA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE wish_list_item (id INT AUTO_INCREMENT NOT NULL, wishlist INT NOT NULL, item INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE wish_list_member (id INT AUTO_INCREMENT NOT NULL, wishlist INT NOT NULL, user INT NOT NULL, can_edit TINYINT(1) NOT NULL, is_accepted TINYINT(1) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE wish_list ADD CONSTRAINT FK_5B8739BDA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); } public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE wish_list DROP FOREIGN KEY FK_5B8739BDA76ED395'); $this->addSql('DROP TABLE item'); $this->addSql('DROP TABLE purchase'); $this->addSql('DROP TABLE user'); diff --git a/web_app/src/Entity/Item.php b/web_app/src/Entity/Item.php index 2f8bea58aae5fed27afc3dde548cabf2b7161137..75a011f862125994f98e04a5600e5c8da8900348 100644 --- a/web_app/src/Entity/Item.php +++ b/web_app/src/Entity/Item.php @@ -33,13 +33,6 @@ class Item return $this->id; } - public function setId(int $id): static - { - $this->id = $id; - - return $this; - } - public function getTitle(): ?string { return $this->title; diff --git a/web_app/src/Entity/Purchase.php b/web_app/src/Entity/Purchase.php index e16508199f956ce8dffcedc6622c6d16dcb364dd..641cf2873f605342b597bba92ea8adeee182716a 100644 --- a/web_app/src/Entity/Purchase.php +++ b/web_app/src/Entity/Purchase.php @@ -16,17 +16,17 @@ class Purchase #[ORM\Column] #[ORM\ManyToOne(targetEntity: User::class)] #[ORM\JoinColumn(nullable: false)] - private ?int $user_id = null; + private ?int $user = null; #[ORM\Column] - #[ORM\ManyToOne(targetEntity: Wishlist::class)] + #[ORM\ManyToOne(targetEntity: WishList::class)] #[ORM\JoinColumn(nullable: false)] - private ?int $wishlist_id = null; + private ?int $wishList = null; #[ORM\Column] #[ORM\ManyToOne(targetEntity: Item::class)] #[ORM\JoinColumn(nullable: false)] - private ?int $item_id = null; + private ?int $item = null; #[ORM\Column(length: 255, nullable: true)] private ?string $url_proof = null; @@ -42,45 +42,38 @@ class Purchase return $this->id; } - public function setId(int $id): static + public function getUser(): ?int { - $this->id = $id; - - return $this; - } - - public function getUserId(): ?int - { - return $this->user_id; + return $this->user; } - public function setUserId(int $user_id): static + public function setUser(int $user): static { - $this->user_id = $user_id; + $this->user = $user; return $this; } - public function getWishlistId(): ?int + public function getWishList(): ?int { - return $this->wishlist_id; + return $this->wishlist; } - public function setWishlistId(int $wishlist_id): static + public function setWishList(int $wishList): static { - $this->wishlist_id = $wishlist_id; + $this->wishList = $wishList; return $this; } - public function getItemId(): ?int + public function getItem(): ?int { - return $this->item_id; + return $this->item; } - public function setItemId(int $item_id): static + public function setItem(int $item): static { - $this->item_id = $item_id; + $this->item = $item; return $this; } diff --git a/web_app/src/Entity/User.php b/web_app/src/Entity/User.php index 3c6a72d9165efcdaf4726b9fdbe9603ab1700e2b..dd3739d1da4abfb16e04fa277c4233122ea61c6f 100644 --- a/web_app/src/Entity/User.php +++ b/web_app/src/Entity/User.php @@ -43,13 +43,6 @@ class User return $this->id; } - public function setId(int $id): static - { - $this->id = $id; - - return $this; - } - public function getUserName(): ?string { return $this->user_name; diff --git a/web_app/src/Entity/WishList.php b/web_app/src/Entity/WishList.php index acbb88b269f95c9e7f5203fc2643f1152f112e8b..59041df37096199575ffcb8c09f26b21ec6e305a 100644 --- a/web_app/src/Entity/WishList.php +++ b/web_app/src/Entity/WishList.php @@ -16,7 +16,7 @@ class WishList #[ORM\ManyToOne(targetEntity: User::class)] #[ORM\JoinColumn(nullable: false)] - private ?int $user_id = null; + private ?int $user = null; #[ORM\Column(length: 255)] private ?string $name = null; @@ -35,21 +35,14 @@ class WishList return $this->id; } - public function setId(int $id): static + public function getUser(): ?User { - $this->id = $id; - - return $this; - } - - public function getUserId(): ?int - { - return $this->user_id; + return $this->user; } - public function setUserId(int $user_id): static + public function setUser(?User $user): static { - $this->user_id = $user_id; + $this->user = $user; return $this; } diff --git a/web_app/src/Entity/WishListItem.php b/web_app/src/Entity/WishListItem.php index 93fb8c6d5a2d45fd3923f0187a57c1384e03bffa..78fa1b775060d5fce1039b8eca2b55658849b6e9 100644 --- a/web_app/src/Entity/WishListItem.php +++ b/web_app/src/Entity/WishListItem.php @@ -14,40 +14,40 @@ class WishListItem private ?int $id = null; #[ORM\Column] - #[ORM\ManyToOne(targetEntity: Wishlist::class)] + #[ORM\ManyToOne(targetEntity: WishList::class)] #[ORM\JoinColumn(nullable: false)] - private ?int $wishlist_id = null; + private ?int $wishList = null; #[ORM\Column] #[ORM\ManyToOne(targetEntity: Item::class)] #[ORM\JoinColumn(nullable: false)] - private ?int $item_id = null; + private ?int $item = null; public function getId(): ?int { return $this->id; } - public function getWishlistId(): ?int + public function getWishList(): ?int { - return $this->wishlist_id; + return $this->wishList; } - public function setWishlistId(int $wishlist_id): static + public function setWishList(int $wishList): static { - $this->wishlist_id = $wishlist_id; + $this->wishList = $wishList; return $this; } - public function getItemId(): ?int + public function getItem(): ?int { return $this->item_id; } - public function setItemId(int $item_id): static + public function setItem(int $item): static { - $this->item_id = $item_id; + $this->item = $item; return $this; } diff --git a/web_app/src/Entity/WishListMember.php b/web_app/src/Entity/WishListMember.php index ab749ccb495236ae32341ebc71ded994bfbb48f7..6646e5a1e0e58ff1e2713aba8d269aa99012074e 100644 --- a/web_app/src/Entity/WishListMember.php +++ b/web_app/src/Entity/WishListMember.php @@ -14,14 +14,14 @@ class WishListMember private ?int $id = null; #[ORM\Column] - #[ORM\ManyToOne(targetEntity: Wishlist::class)] + #[ORM\ManyToOne(targetEntity: WishList::class)] #[ORM\JoinColumn(nullable: false)] - private ?int $wishlist_id = null; + private ?int $wishList = null; #[ORM\Column] #[ORM\ManyToOne(targetEntity: User::class)] #[ORM\JoinColumn(nullable: false)] - private ?int $user_id = null; + private ?int $user = null; #[ORM\Column] private ?bool $can_edit = null; @@ -37,26 +37,26 @@ class WishListMember return $this->id; } - public function getWishlistId(): ?int + public function getWishList(): ?int { - return $this->wishlist_id; + return $this->wishList; } - public function setWishlistId(int $wishlist_id): static + public function setWishList(int $wishList): static { - $this->wishlist_id = $wishlist_id; + $this->wishList = $wishList; return $this; } - public function getUserId(): ?int + public function getUser(): ?int { - return $this->user_id; + return $this->user; } - public function setUserId(int $user_id): static + public function setUser(int $user): static { - $this->user_id = $user_id; + $this->user = $user; return $this; } @@ -96,11 +96,4 @@ class WishListMember return $this; } - - public function setId(?Wishlist $id): static - { - $this->id = $id; - - return $this; - } }