diff --git a/migrations/Version20241017134137.php b/migrations/Version20241017134137.php new file mode 100644 index 0000000..0dc3e3c --- /dev/null +++ b/migrations/Version20241017134137.php @@ -0,0 +1,67 @@ +addSql('CREATE SEQUENCE announcement_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE company_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE userApp_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE announcement (id INT NOT NULL, title VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE company (id INT NOT NULL, name VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, tel VARCHAR(255) NOT NULL, mail VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE employee (id INT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE intern (id INT NOT NULL, cover_letter TEXT NOT NULL, resume VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE userApp (id INT NOT NULL, nickname VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, tel VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, mail VARCHAR(255) NOT NULL, DISCRIMINATOR VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_NICKNAME ON userApp (nickname)'); + $this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)'); + $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)'); + $this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)'); + $this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$ + BEGIN + PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text); + RETURN NEW; + END; + $$ LANGUAGE plpgsql;'); + $this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;'); + $this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();'); + $this->addSql('ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A1BF396750 FOREIGN KEY (id) REFERENCES userApp (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE intern ADD CONSTRAINT FK_A5795F36BF396750 FOREIGN KEY (id) REFERENCES userApp (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('DROP SEQUENCE announcement_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE company_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE userApp_id_seq CASCADE'); + $this->addSql('ALTER TABLE employee DROP CONSTRAINT FK_5D9F75A1BF396750'); + $this->addSql('ALTER TABLE intern DROP CONSTRAINT FK_A5795F36BF396750'); + $this->addSql('DROP TABLE announcement'); + $this->addSql('DROP TABLE company'); + $this->addSql('DROP TABLE employee'); + $this->addSql('DROP TABLE intern'); + $this->addSql('DROP TABLE userApp'); + $this->addSql('DROP TABLE messenger_messages'); + } +} diff --git a/migrations/Version20241017142722.php b/migrations/Version20241017142722.php new file mode 100644 index 0000000..73818a8 --- /dev/null +++ b/migrations/Version20241017142722.php @@ -0,0 +1,52 @@ +addSql('CREATE SEQUENCE status_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE status (id INT NOT NULL, label VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('ALTER TABLE announcement ADD company_id INT NOT NULL'); + $this->addSql('ALTER TABLE announcement ADD status_id INT NOT NULL'); + $this->addSql('ALTER TABLE announcement ADD CONSTRAINT FK_4DB9D91C979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE announcement ADD CONSTRAINT FK_4DB9D91C6BF700BD FOREIGN KEY (status_id) REFERENCES status (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_4DB9D91C979B1AD6 ON announcement (company_id)'); + $this->addSql('CREATE INDEX IDX_4DB9D91C6BF700BD ON announcement (status_id)'); + $this->addSql('ALTER TABLE employee ADD company_id INT NOT NULL'); + $this->addSql('ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A1979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_5D9F75A1979B1AD6 ON employee (company_id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE announcement DROP CONSTRAINT FK_4DB9D91C6BF700BD'); + $this->addSql('DROP SEQUENCE status_id_seq CASCADE'); + $this->addSql('DROP TABLE status'); + $this->addSql('ALTER TABLE announcement DROP CONSTRAINT FK_4DB9D91C979B1AD6'); + $this->addSql('DROP INDEX IDX_4DB9D91C979B1AD6'); + $this->addSql('DROP INDEX IDX_4DB9D91C6BF700BD'); + $this->addSql('ALTER TABLE announcement DROP company_id'); + $this->addSql('ALTER TABLE announcement DROP status_id'); + $this->addSql('ALTER TABLE employee DROP CONSTRAINT FK_5D9F75A1979B1AD6'); + $this->addSql('DROP INDEX IDX_5D9F75A1979B1AD6'); + $this->addSql('ALTER TABLE employee DROP company_id'); + } +} diff --git a/migrations/Version20241017152949.php b/migrations/Version20241017152949.php new file mode 100644 index 0000000..1282d23 --- /dev/null +++ b/migrations/Version20241017152949.php @@ -0,0 +1,46 @@ +addSql('CREATE TABLE favorites (intern_id INT NOT NULL, announcement_id INT NOT NULL, PRIMARY KEY(intern_id, announcement_id))'); + $this->addSql('CREATE INDEX IDX_E46960F5525DD4B4 ON favorites (intern_id)'); + $this->addSql('CREATE INDEX IDX_E46960F5913AEA17 ON favorites (announcement_id)'); + $this->addSql('CREATE TABLE applications (intern_id INT NOT NULL, announcement_id INT NOT NULL, PRIMARY KEY(intern_id, announcement_id))'); + $this->addSql('CREATE INDEX IDX_F7C966F0525DD4B4 ON applications (intern_id)'); + $this->addSql('CREATE INDEX IDX_F7C966F0913AEA17 ON applications (announcement_id)'); + $this->addSql('ALTER TABLE favorites ADD CONSTRAINT FK_E46960F5525DD4B4 FOREIGN KEY (intern_id) REFERENCES intern (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE favorites ADD CONSTRAINT FK_E46960F5913AEA17 FOREIGN KEY (announcement_id) REFERENCES announcement (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE applications ADD CONSTRAINT FK_F7C966F0525DD4B4 FOREIGN KEY (intern_id) REFERENCES intern (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE applications ADD CONSTRAINT FK_F7C966F0913AEA17 FOREIGN KEY (announcement_id) REFERENCES announcement (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE favorites DROP CONSTRAINT FK_E46960F5525DD4B4'); + $this->addSql('ALTER TABLE favorites DROP CONSTRAINT FK_E46960F5913AEA17'); + $this->addSql('ALTER TABLE applications DROP CONSTRAINT FK_F7C966F0525DD4B4'); + $this->addSql('ALTER TABLE applications DROP CONSTRAINT FK_F7C966F0913AEA17'); + $this->addSql('DROP TABLE favorites'); + $this->addSql('DROP TABLE applications'); + } +} diff --git a/src/Entity/Obtaining.php b/src/Entity/Obtaining.php new file mode 100644 index 0000000..cecb3c1 --- /dev/null +++ b/src/Entity/Obtaining.php @@ -0,0 +1,36 @@ +id; + } + + public function getDate(): ?\DateTimeInterface + { + return $this->date; + } + + public function setDate(\DateTimeInterface $date): static + { + $this->date = $date; + + return $this; + } +} diff --git a/src/Entity/Status.php b/src/Entity/Status.php new file mode 100644 index 0000000..e672f8c --- /dev/null +++ b/src/Entity/Status.php @@ -0,0 +1,78 @@ + + */ + #[ORM\OneToMany(targetEntity: Announcement::class, mappedBy: 'status')] + private Collection $announcements; + + public function __construct() + { + $this->announcements = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(string $label): static + { + $this->label = $label; + + return $this; + } + + /** + * @return Collection + */ + public function getAnnouncements(): Collection + { + return $this->announcements; + } + + public function addAnnouncement(Announcement $announcement): static + { + if (!$this->announcements->contains($announcement)) { + $this->announcements->add($announcement); + $announcement->setStatus($this); + } + + return $this; + } + + public function removeAnnouncement(Announcement $announcement): static + { + if ($this->announcements->removeElement($announcement)) { + // set the owning side to null (unless already changed) + if ($announcement->getStatus() === $this) { + $announcement->setStatus(null); + } + } + + return $this; + } +} diff --git a/src/Repository/StatusRepository.php b/src/Repository/StatusRepository.php new file mode 100644 index 0000000..ea2e260 --- /dev/null +++ b/src/Repository/StatusRepository.php @@ -0,0 +1,43 @@ + + */ +class StatusRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Status::class); + } + +// /** +// * @return Status[] Returns an array of Status objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('v') +// ->andWhere('v.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('v.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Status +// { +// return $this->createQueryBuilder('v') +// ->andWhere('v.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +}