From a711b575f7e4fd56675c04b9a35815d2ed1181de Mon Sep 17 00:00:00 2001 From: Patrycja Date: Fri, 22 Feb 2019 15:57:41 +0100 Subject: [PATCH] Review 1 --- config/routes.yaml | 2 + config/routes/library.yaml | 5 + src/Controller/AuthorController.php | 112 +++++++++++++ src/Controller/BookController.php | 114 ++++++++++++++ src/Controller/GenreController.php | 116 ++++++++++++++ src/Controller/LibraryController.php | 27 ++++ src/Controller/LibraryMenuController.php | 15 ++ src/Entity/Author.php | 130 ++++++++++++++++ src/Entity/Book.php | 156 +++++++++++++++++++ src/Entity/Genre.php | 61 ++++++++ src/Form/AuthorType.php | 36 +++++ src/Form/BookType.php | 49 ++++++ src/Form/GenreType.php | 28 ++++ src/Migrations/Version20190220112732.php | 35 +++++ src/Migrations/Version20190220113535.php | 35 +++++ src/Migrations/Version20190220115605.php | 35 +++++ src/Migrations/Version20190221112059.php | 43 +++++ src/Migrations/Version20190221112248.php | 39 +++++ src/Repository/AuthorRepository.php | 50 ++++++ src/Repository/BookRepository.php | 50 ++++++ src/Repository/GenreRepository.php | 50 ++++++ src/Repository/ProductCategoryRepository.php | 5 +- templates/author/_delete_form.html.twig | 5 + templates/author/_form.html.twig | 4 + templates/author/edit.html.twig | 13 ++ templates/author/index.html.twig | 43 +++++ templates/author/new.html.twig | 11 ++ templates/author/show.html.twig | 60 +++++++ templates/baselibrary.html.twig | 36 +++++ templates/book/_delete_form.html.twig | 5 + templates/book/_form.html.twig | 4 + templates/book/edit.html.twig | 13 ++ templates/book/index.html.twig | 51 ++++++ templates/book/new.html.twig | 11 ++ templates/book/show.html.twig | 50 ++++++ templates/genre/_delete_form.html.twig | 5 + templates/genre/_form.html.twig | 4 + templates/genre/edit.html.twig | 13 ++ templates/genre/index.html.twig | 38 +++++ templates/genre/new.html.twig | 11 ++ templates/genre/show.html.twig | 30 ++++ templates/library.html.twig | 27 ++++ templates/menu.html.twig | 16 +- templates/menulibrary.html.twig | 12 ++ templates/product_category/index.html.twig | 4 +- templates/product_category/show.html.twig | 2 +- templates/welcome.html.twig | 2 +- 47 files changed, 1649 insertions(+), 14 deletions(-) create mode 100644 config/routes/library.yaml create mode 100644 src/Controller/AuthorController.php create mode 100644 src/Controller/BookController.php create mode 100644 src/Controller/GenreController.php create mode 100644 src/Controller/LibraryController.php create mode 100644 src/Controller/LibraryMenuController.php create mode 100644 src/Entity/Author.php create mode 100644 src/Entity/Book.php create mode 100644 src/Entity/Genre.php create mode 100644 src/Form/AuthorType.php create mode 100644 src/Form/BookType.php create mode 100644 src/Form/GenreType.php create mode 100644 src/Migrations/Version20190220112732.php create mode 100644 src/Migrations/Version20190220113535.php create mode 100644 src/Migrations/Version20190220115605.php create mode 100644 src/Migrations/Version20190221112059.php create mode 100644 src/Migrations/Version20190221112248.php create mode 100644 src/Repository/AuthorRepository.php create mode 100644 src/Repository/BookRepository.php create mode 100644 src/Repository/GenreRepository.php create mode 100644 templates/author/_delete_form.html.twig create mode 100644 templates/author/_form.html.twig create mode 100644 templates/author/edit.html.twig create mode 100644 templates/author/index.html.twig create mode 100644 templates/author/new.html.twig create mode 100644 templates/author/show.html.twig create mode 100644 templates/baselibrary.html.twig create mode 100644 templates/book/_delete_form.html.twig create mode 100644 templates/book/_form.html.twig create mode 100644 templates/book/edit.html.twig create mode 100644 templates/book/index.html.twig create mode 100644 templates/book/new.html.twig create mode 100644 templates/book/show.html.twig create mode 100644 templates/genre/_delete_form.html.twig create mode 100644 templates/genre/_form.html.twig create mode 100644 templates/genre/edit.html.twig create mode 100644 templates/genre/index.html.twig create mode 100644 templates/genre/new.html.twig create mode 100644 templates/genre/show.html.twig create mode 100644 templates/library.html.twig create mode 100644 templates/menulibrary.html.twig diff --git a/config/routes.yaml b/config/routes.yaml index c3283aa..cc33a34 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -1,3 +1,5 @@ #index: # path: / # controller: App\Controller\DefaultController::index + + diff --git a/config/routes/library.yaml b/config/routes/library.yaml new file mode 100644 index 0000000..c704783 --- /dev/null +++ b/config/routes/library.yaml @@ -0,0 +1,5 @@ + + +app_welcome: + path: /library + controller: App\Controller\LibraryController::libraryAction \ No newline at end of file diff --git a/src/Controller/AuthorController.php b/src/Controller/AuthorController.php new file mode 100644 index 0000000..fa0d3bc --- /dev/null +++ b/src/Controller/AuthorController.php @@ -0,0 +1,112 @@ +render('author/index.html.twig', [ + 'authors' => $authorRepository->findAll(), + ]); + } + + /** + * @Route("/new", name="author_new", methods={"GET","POST"}) + */ + public function new(Request $request): Response + { + $author = new author(); + $form = $this->createForm(AuthorType::class, $author); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($author); + $entityManager->flush(); + + $this->addFlash('notice', + ' Author was added!'); + + return $this->redirectToRoute('author_index'); + } + + return $this->render('author/new.html.twig', [ + 'author' => $author, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="author_show", methods={"GET"}) + */ + public function show(Author $author): Response + { + + $this->addFlash('notice', + 'This is your author!'); + + return $this->render('author/show.html.twig', [ + 'author' => $author, + ]); + } + + /** + * @Route("/{id}/edit", name="author_edit", methods={"GET","POST"}) + */ + public function edit(Request $request, Author $author): Response + { + $form = $this->createForm(AuthorType::class, $author); + $form->handleRequest($request); + + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('notice', + 'Your changes about an author have been saved!'); + + + return $this->redirectToRoute('author_index', [ + 'id' => $author->getId(), + ]); + } + + return $this->render('author/edit.html.twig', [ + 'author' => $author, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="author_delete", methods={"DELETE"}) + */ + public function delete(Request $request, Author $author): Response + { + if ($this->isCsrfTokenValid('delete'.$author->getId(), $request->request->get('_token'))) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->remove($author); + $entityManager->flush(); + + $this->addFlash('notice', + 'You have been deleted an author!'); + } + + return $this->redirectToRoute('author_index'); + } +} diff --git a/src/Controller/BookController.php b/src/Controller/BookController.php new file mode 100644 index 0000000..2d2451a --- /dev/null +++ b/src/Controller/BookController.php @@ -0,0 +1,114 @@ +render('book/index.html.twig', [ + 'books' => $bookRepository->findAll(), + ]); + } + + /** + * @Route("/new", name="book_new", methods={"GET","POST"}) + */ + public function new(Request $request): Response + { + $book = new Book(); + $form = $this->createForm(BookType::class, $book); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($book); + $entityManager->flush(); + + + + + return $this->redirectToRoute('book_index'); + } + + return $this->render('book/new.html.twig', [ + 'book' => $book, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="book_show", methods={"GET"}) + */ + public function show(Book $book): Response + { + + $this->addFlash('notice', + 'This is your book!' + + ); + + return $this->render('book/show.html.twig', [ + 'book' => $book, + ]); + } + + /** + * @Route("/{id}/edit", name="book_edit", methods={"GET","POST"}) + */ + public function edit(Request $request, Book $book): Response + { + $form = $this->createForm(BookType::class, $book); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('notice', + 'Book has been edited!' + ); + + return $this->redirectToRoute('book_index', [ + 'id' => $book->getId(), + ]); + } + + return $this->render('book/edit.html.twig', [ + 'book' => $book, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="book_delete", methods={"DELETE"}) + */ + public function delete(Request $request, Book $book): Response + { + if ($this->isCsrfTokenValid('delete'.$book->getId(), $request->request->get('_token'))) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->remove($book); + $entityManager->flush(); + + $this->addFlash('notice', + 'Book has been deleted!' + ); + } + + return $this->redirectToRoute('book_index'); + + } +} diff --git a/src/Controller/GenreController.php b/src/Controller/GenreController.php new file mode 100644 index 0000000..3b54223 --- /dev/null +++ b/src/Controller/GenreController.php @@ -0,0 +1,116 @@ +render('genre/index.html.twig', [ + 'genres' => $genreRepository->findAll(), + ]); + } + + /** + * @Route("/new", name="genre_new", methods={"GET","POST"}) + */ + public function new(Request $request): Response + { + $genre = new Genre(); + $form = $this->createForm(GenreType::class, $genre); + $form->handleRequest($request); + + + + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($genre); + $entityManager->flush(); + + + $this->addFlash('notice', + ' Genre {{ path(\'genre_show\', {id: genre.id}) }}"> {{ genre.name }} was added!'); + + return $this->redirectToRoute('genre_index'); + } + + return $this->render('genre/new.html.twig', [ + 'genre' => $genre, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="genre_show", methods={"GET"}) + */ + public function show(Genre $genre): Response + { + $this->addFlash('notice', + 'This is your genre!'); + + return $this->render('genre/show.html.twig', [ + 'genre' => $genre, + ]); + } + + /** + * @Route("/{id}/edit", name="genre_edit", methods={"GET","POST"}) + */ + public function edit(Request $request, Genre $genre): Response + { + $form = $this->createForm(GenreType::class, $genre); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + $this->addFlash('notice', + 'Genre has been updated!'); + + return $this->redirectToRoute('genre_index', [ + 'id' => $genre->getId(), + ]); + } + + return $this->render('genre/edit.html.twig', [ + 'genre' => $genre, + 'form' => $form->createView(), + ]); + } + + /** + * @Route("/{id}", name="genre_delete", methods={"DELETE"}) + */ + public function delete(Request $request, Genre $genre): Response + { + if ($this->isCsrfTokenValid('delete'.$genre->getId(), $request->request->get('_token'))) { + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->remove($genre); + $entityManager->flush(); + + $this->addFlash('notice', + 'Genre has been deleted!' ); + } + + return $this->redirectToRoute('genre_index'); + } +} diff --git a/src/Controller/LibraryController.php b/src/Controller/LibraryController.php new file mode 100644 index 0000000..5e5ff9e --- /dev/null +++ b/src/Controller/LibraryController.php @@ -0,0 +1,27 @@ + render('library.html.twig',[ 'data' => $dataAction]); + } + +} diff --git a/src/Controller/LibraryMenuController.php b/src/Controller/LibraryMenuController.php new file mode 100644 index 0000000..54f39e8 --- /dev/null +++ b/src/Controller/LibraryMenuController.php @@ -0,0 +1,15 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + public function getSurname(): ?string + { + return $this->surname; + } + + public function setSurname(string $surname): self + { + $this->surname = $surname; + + return $this; + } + + public function getCountry(): ?string + { + return $this->country; + } + + public function setCountry(string $country): self + { + $this->country = $country; + + return $this; + } + + public function getBirthYear(): ?int + { + return $this->birthYear; + } + + public function setBirthYear(int $birthYear): self + { + $this->birthYear = $birthYear; + + return $this; + } + + public function getDeathYear(): ?int + + { + return $this->deathYear; + } + + public function setDeathYear(int $deathYear): self + { + $this->deathYear = $deathYear; + + return $this; + } + + public function getBook(): ?string + { + return $this->Book; + } + + public function setBook(string $Book): self + { + $this->Book = $Book; + + return $this; + } +} diff --git a/src/Entity/Book.php b/src/Entity/Book.php new file mode 100644 index 0000000..adc9371 --- /dev/null +++ b/src/Entity/Book.php @@ -0,0 +1,156 @@ +id; + } + + public function getTitle(): ?string + { + return $this->title; + } + + public function setTitle(string $title): self + { + $this->title = $title; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(string $description): self + { + $this->description = $description; + + return $this; + } + + public function getAuthor(): ?string + { + return $this->author; + } + + public function setAuthor(string $author): self + { + $this->author = $author; + + return $this; + } + + public function getGenre(): ?string + { + return $this->genre; + } + + public function setGenre(string $genre): self + { + $this->genre = $genre; + + return $this; + } + + public function getDateOfPublishment(): ?int + { + return $this->dateOfPublishment; + } + + public function setDateOfPublishment(int $dateOfPublishment): self + { + $this->dateOfPublishment = $dateOfPublishment; + + return $this; + } + + public function getCountryOfPublishment(): ?string + { + return $this->countryOfPublishment; + } + + public function setCountryOfPublishment(string $countryOfPublishment): self + { + $this->countryOfPublishment = $countryOfPublishment; + + return $this; + } + + public function getAvailability(): ?bool + { + return $this->availability; + } + + public function setAvailability(bool $availability): self + { + $this->availability = $availability; + + return $this; + } + + public function getAuthors(): ?Author + { + return $this->authors; + } + + public function setAuthors(?Author $authors): self + { + $this->authors = $authors; + + return $this; + } + +} \ No newline at end of file diff --git a/src/Entity/Genre.php b/src/Entity/Genre.php new file mode 100644 index 0000000..dc20f7f --- /dev/null +++ b/src/Entity/Genre.php @@ -0,0 +1,61 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + + return $this; + + }} diff --git a/src/Form/AuthorType.php b/src/Form/AuthorType.php new file mode 100644 index 0000000..b1c068d --- /dev/null +++ b/src/Form/AuthorType.php @@ -0,0 +1,36 @@ +add('Name', TextType::class, []) + ->add('Surname', TextType::class, []) + ->add('Country', CountryType::class, + []) + ->add('birthYear', NumberType::class, [] + ) + ->add('deathYear', NumberType::class, [] + ) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Author::class, + ]); + } +} diff --git a/src/Form/BookType.php b/src/Form/BookType.php new file mode 100644 index 0000000..b44d9c7 --- /dev/null +++ b/src/Form/BookType.php @@ -0,0 +1,49 @@ +add('title', TextType::class, []) + ->add('description', TextareaType::class, [ 'required' => false]) + + ->add('author', EntityType::class, + ['class' => Author::class, + 'choice_label' => 'name']) + ->add('genre', EntityType::class, + ['class' => Genre::class, + 'choice_label' => 'name']) + ->add('dateOfPublishment', DateType::class, [] + ) + ->add('countryOfPublishment', CountryType::class, + []) + ->add('availability', CheckboxType::class, ['required' => false]) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Book::class, + ]); + } +} \ No newline at end of file diff --git a/src/Form/GenreType.php b/src/Form/GenreType.php new file mode 100644 index 0000000..e233e51 --- /dev/null +++ b/src/Form/GenreType.php @@ -0,0 +1,28 @@ +add('name', TextType::class, []) + ->add('description', TextareaType::class, ['required' => false]) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Genre::class, + ]); + } +} diff --git a/src/Migrations/Version20190220112732.php b/src/Migrations/Version20190220112732.php new file mode 100644 index 0000000..3881e1b --- /dev/null +++ b/src/Migrations/Version20190220112732.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE book (id INT AUTO_INCREMENT NOT NULL, title LONGTEXT NOT NULL, description LONGTEXT NOT NULL, author VARCHAR(255) NOT NULL, genre VARCHAR(255) NOT NULL, date_of_publishment DATE NOT NULL, country_of_publishment VARCHAR(255) NOT NULL, availability VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE book'); + } +} diff --git a/src/Migrations/Version20190220113535.php b/src/Migrations/Version20190220113535.php new file mode 100644 index 0000000..bd135fe --- /dev/null +++ b/src/Migrations/Version20190220113535.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE author (id INT AUTO_INCREMENT NOT NULL, name LONGTEXT NOT NULL, surname LONGTEXT NOT NULL, country LONGTEXT NOT NULL, birth_year DATE NOT NULL, death_year DATE DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE author'); + } +} diff --git a/src/Migrations/Version20190220115605.php b/src/Migrations/Version20190220115605.php new file mode 100644 index 0000000..1f57b45 --- /dev/null +++ b/src/Migrations/Version20190220115605.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE genre (id INT AUTO_INCREMENT NOT NULL, name LONGTEXT NOT NULL, description LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE genre'); + } +} diff --git a/src/Migrations/Version20190221112059.php b/src/Migrations/Version20190221112059.php new file mode 100644 index 0000000..9f4d910 --- /dev/null +++ b/src/Migrations/Version20190221112059.php @@ -0,0 +1,43 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE book ADD authors_id INT NOT NULL, CHANGE title title VARCHAR(255) NOT NULL, CHANGE description description VARCHAR(255) NOT NULL, CHANGE date_of_publishment date_of_publishment INT NOT NULL, CHANGE availability availability TINYINT(1) NOT NULL'); + $this->addSql('ALTER TABLE book ADD CONSTRAINT FK_CBE5A3316DE2013A FOREIGN KEY (authors_id) REFERENCES author (id)'); + $this->addSql('CREATE INDEX IDX_CBE5A3316DE2013A ON book (authors_id)'); + $this->addSql('ALTER TABLE author ADD book VARCHAR(255) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE surname surname VARCHAR(255) NOT NULL, CHANGE country country VARCHAR(255) NOT NULL, CHANGE birth_year birth_year INT NOT NULL, CHANGE death_year death_year INT DEFAULT NULL'); + $this->addSql('ALTER TABLE genre CHANGE name name VARCHAR(255) NOT NULL, CHANGE description description VARCHAR(255) NOT NULL'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE author DROP book, CHANGE name name LONGTEXT NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE surname surname LONGTEXT NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE country country LONGTEXT NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE birth_year birth_year DATE NOT NULL, CHANGE death_year death_year DATE DEFAULT NULL'); + $this->addSql('ALTER TABLE book DROP FOREIGN KEY FK_CBE5A3316DE2013A'); + $this->addSql('DROP INDEX IDX_CBE5A3316DE2013A ON book'); + $this->addSql('ALTER TABLE book DROP authors_id, CHANGE title title LONGTEXT NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE description description LONGTEXT NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE date_of_publishment date_of_publishment DATE NOT NULL, CHANGE availability availability VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci'); + $this->addSql('ALTER TABLE genre CHANGE name name LONGTEXT NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE description description LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci'); + } +} diff --git a/src/Migrations/Version20190221112248.php b/src/Migrations/Version20190221112248.php new file mode 100644 index 0000000..186b2df --- /dev/null +++ b/src/Migrations/Version20190221112248.php @@ -0,0 +1,39 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE book ADD relationship_id INT NOT NULL'); + $this->addSql('ALTER TABLE book ADD CONSTRAINT FK_CBE5A3312C41D668 FOREIGN KEY (relationship_id) REFERENCES genre (id)'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_CBE5A3312C41D668 ON book (relationship_id)'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE book DROP FOREIGN KEY FK_CBE5A3312C41D668'); + $this->addSql('DROP INDEX UNIQ_CBE5A3312C41D668 ON book'); + $this->addSql('ALTER TABLE book DROP relationship_id'); + } +} diff --git a/src/Repository/AuthorRepository.php b/src/Repository/AuthorRepository.php new file mode 100644 index 0000000..1cee46b --- /dev/null +++ b/src/Repository/AuthorRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('a.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Author + { + return $this->createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/BookRepository.php b/src/Repository/BookRepository.php new file mode 100644 index 0000000..997b0d2 --- /dev/null +++ b/src/Repository/BookRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('b') + ->andWhere('b.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('b.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Book + { + return $this->createQueryBuilder('b') + ->andWhere('b.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/GenreRepository.php b/src/Repository/GenreRepository.php new file mode 100644 index 0000000..2ef17fc --- /dev/null +++ b/src/Repository/GenreRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('g') + ->andWhere('g.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('g.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Genre + { + return $this->createQueryBuilder('g') + ->andWhere('g.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/ProductCategoryRepository.php b/src/Repository/ProductCategoryRepository.php index 3e3dbcf..8774d1b 100644 --- a/src/Repository/ProductCategoryRepository.php +++ b/src/Repository/ProductCategoryRepository.php @@ -35,7 +35,7 @@ public function __construct(RegistryInterface $registry) */ - /* + /* /* public function findOneBySomeField($value): ?ProductCategory { return $this->createQueryBuilder('p') @@ -49,4 +49,5 @@ public function findOneBySomeField($value): ?ProductCategory } -} \ No newline at end of file +} + */ \ No newline at end of file diff --git a/templates/author/_delete_form.html.twig b/templates/author/_delete_form.html.twig new file mode 100644 index 0000000..a8f55c9 --- /dev/null +++ b/templates/author/_delete_form.html.twig @@ -0,0 +1,5 @@ +
+ + + +
diff --git a/templates/author/_form.html.twig b/templates/author/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/author/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/author/edit.html.twig b/templates/author/edit.html.twig new file mode 100644 index 0000000..2460620 --- /dev/null +++ b/templates/author/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'library.html.twig' %} + +{% block title %}Edit Author{% endblock %} + +{% block body %} +

Edit Author

+ + {{ include('author/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('author/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/author/index.html.twig b/templates/author/index.html.twig new file mode 100644 index 0000000..ba060d4 --- /dev/null +++ b/templates/author/index.html.twig @@ -0,0 +1,43 @@ +{% extends 'library.html.twig' %} + +{% block title %}Author index{% endblock %} + +{% block body %} +

Author index

+ + + + + + + + + + + + + + + {% for author in authors %} + + + + + + + + + + {% else %} + + + + {% endfor %} + +
IdNameSurnameCountryBirthYearDeathYearactions
{{ author.id }}{{ author.Name }}{{ author.Surname }}{{ author.Country }}{{ author.birthYear ? author.birthYear|date('Y-m-d') : '' }}{{ author.deathYear ? author.deathYear|date('Y-m-d') : '' }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/author/new.html.twig b/templates/author/new.html.twig new file mode 100644 index 0000000..71e465c --- /dev/null +++ b/templates/author/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'library.html.twig' %} + +{% block title %}New Author{% endblock %} + +{% block body %} +

Create new Author

+ + {{ include('author/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/author/show.html.twig b/templates/author/show.html.twig new file mode 100644 index 0000000..cb41c8b --- /dev/null +++ b/templates/author/show.html.twig @@ -0,0 +1,60 @@ +{% extends 'library.html.twig' %} + +{% block title %}Author{% endblock %} + +{% block body %} +

Author

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ author.id }}
Name{{ author.Name }}
Surname{{ author.Surname }}
Country{{ author.Country }}
BirthYear{{ author.birthYear ? author.birthYear|date('Y') : '' }}
DeathYear{{ author.deathYear ? author.deathYear|date('Y') : ''}}
Title{{ book.Name }}
Genre{{ genre.Name }}
Date of publishment {{ book.dateOfPublishment }}
+ + back to list + + edit + + {{ include('author/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/baselibrary.html.twig b/templates/baselibrary.html.twig new file mode 100644 index 0000000..d426a83 --- /dev/null +++ b/templates/baselibrary.html.twig @@ -0,0 +1,36 @@ + + + + + {% block title %}Welcome!{% endblock %} + {% block stylesheets %}{% endblock %} + {% block head_css %} + + {% endblock %} + {% block head_js %} + + + + {% endblock %} + + + + +
+ {% for label, messages in app.flashes %} + {% for message in messages %} + +
+ {{ message }} +
+ {% endfor %} + {% endfor %} + + {% block body %}{% endblock %} + {% block javascripts %}{% endblock %} + + + +
+ + diff --git a/templates/book/_delete_form.html.twig b/templates/book/_delete_form.html.twig new file mode 100644 index 0000000..68d5aa6 --- /dev/null +++ b/templates/book/_delete_form.html.twig @@ -0,0 +1,5 @@ +
+ + + +
diff --git a/templates/book/_form.html.twig b/templates/book/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/book/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/book/edit.html.twig b/templates/book/edit.html.twig new file mode 100644 index 0000000..ad441c7 --- /dev/null +++ b/templates/book/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Book{% endblock %} + +{% block body %} +

Edit Book

+ + {{ include('book/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('book/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/book/index.html.twig b/templates/book/index.html.twig new file mode 100644 index 0000000..1146a44 --- /dev/null +++ b/templates/book/index.html.twig @@ -0,0 +1,51 @@ +{% extends 'library.html.twig' %} + +{% block title %}Book index{% endblock %} + +{% block body %} +

Book index

+ + + + + + + + + + + + + + + + + + + {% for book in books %} + + + + + + + + + + + + + + {% else %} + + + + {% endfor %} + +
Id TitleDescriptionAuthorGenreDateOfPublishment CountryOfPublishmentDate_of_creationDate_of_last_modificationAvailabilityactions
{{ book.id }}{{ book.title }}{{ book.description }}{{ book.author }}{{ book.genre }}{{ book.dateOfPublishment ? book.dateOfPublishment|date('Y-m-d') : '' }}{{ book.countryOfPublishment }}{{ product.dateOfCreation|date("m/d/Y") }}{{ product.dateOfLastModification|date("m/d/Y") }}{{ book.availability }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/book/new.html.twig b/templates/book/new.html.twig new file mode 100644 index 0000000..7d50344 --- /dev/null +++ b/templates/book/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'baselibrary.html.twig' %} + +{% block title %}New Book{% endblock %} + +{% block body %} +

Create new Book

+ + {{ include('book/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/book/show.html.twig b/templates/book/show.html.twig new file mode 100644 index 0000000..3ac5401 --- /dev/null +++ b/templates/book/show.html.twig @@ -0,0 +1,50 @@ + + +{% block title %}Book{% endblock %} + +{% block body %} +

Book

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ book.id }}
Title{{ book.title }}
Description{{ book.description }}
Author{{ book.author }}
Genre{{ book.genre }}
DateOfPublishment{{ book.dateOfPublishment ? book.dateOfPublishment|date('Y-m-d') : '' }}
CountryOfPublishment{{ book.countryOfPublishment }}
Availability{{ book.availability }}
+ + back to list + + edit + + {{ include('book/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/genre/_delete_form.html.twig b/templates/genre/_delete_form.html.twig new file mode 100644 index 0000000..be6551b --- /dev/null +++ b/templates/genre/_delete_form.html.twig @@ -0,0 +1,5 @@ +
+ + + +
diff --git a/templates/genre/_form.html.twig b/templates/genre/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/genre/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/genre/edit.html.twig b/templates/genre/edit.html.twig new file mode 100644 index 0000000..fa7e432 --- /dev/null +++ b/templates/genre/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Genre{% endblock %} + +{% block body %} +

Edit Genre

+ + {{ include('genre/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('genre/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/genre/index.html.twig b/templates/genre/index.html.twig new file mode 100644 index 0000000..f3be2f5 --- /dev/null +++ b/templates/genre/index.html.twig @@ -0,0 +1,38 @@ +{% extends 'base.html.twig' %} + +{% block title %}Genre index{% endblock %} + +{% block body %} +

Genre index

+ + + + + + + + + + + + + {% for genre in genres %} + + + + + + + {% else %} + + + + {% endfor %} + +
IdNameDescriptionactions
{{ genre.id }}{{ genre.name }}{{ genre.description }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/genre/new.html.twig b/templates/genre/new.html.twig new file mode 100644 index 0000000..766d78e --- /dev/null +++ b/templates/genre/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Genre{% endblock %} + +{% block body %} +

Create new Genre

+ + {{ include('genre/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/genre/show.html.twig b/templates/genre/show.html.twig new file mode 100644 index 0000000..a97be81 --- /dev/null +++ b/templates/genre/show.html.twig @@ -0,0 +1,30 @@ +{% extends 'base.html.twig' %} + +{% block title %}Genre{% endblock %} + +{% block body %} +

Genre

+ + + + + + + + + + + + + + + + +
Id{{ genre.id }}
Name{{ genre.name }}
Description{{ genre.description }}
+ + back to list + + edit + + {{ include('genre/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/library.html.twig b/templates/library.html.twig new file mode 100644 index 0000000..b5575a9 --- /dev/null +++ b/templates/library.html.twig @@ -0,0 +1,27 @@ + +{% extends 'baselibrary.html.twig' %} + +{% block title %}Library{% endblock %} + +{% block body %} + + + Today is {{ data }} + +

+ + + This is LibraryApp. Click and see: +

+ +

+ + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/menu.html.twig b/templates/menu.html.twig index 699b52a..10d945a 100644 --- a/templates/menu.html.twig +++ b/templates/menu.html.twig @@ -1,11 +1,11 @@ \ No newline at end of file diff --git a/templates/menulibrary.html.twig b/templates/menulibrary.html.twig new file mode 100644 index 0000000..ea9a680 --- /dev/null +++ b/templates/menulibrary.html.twig @@ -0,0 +1,12 @@ +{# +#} diff --git a/templates/product_category/index.html.twig b/templates/product_category/index.html.twig index 364f7bc..5a7d785 100644 --- a/templates/product_category/index.html.twig +++ b/templates/product_category/index.html.twig @@ -22,8 +22,8 @@ {{ product_category.id }} {{ product_category.name }} {{ product_category.description }} - {{ product_category.dateOfCreation|date("m/d/Y") }} - {{ product_category.dateOfLastModification|date("m/d/Y") }} + {{ product_category.dateOfCreation|date("Y") }} + {{ product_category.dateOfLastModification|date("Y") }} show edit diff --git a/templates/product_category/show.html.twig b/templates/product_category/show.html.twig index f81d886..3fb2379 100644 --- a/templates/product_category/show.html.twig +++ b/templates/product_category/show.html.twig @@ -1,4 +1,4 @@ -{% extends 'base.html.twig' %} +{% extends 'baselibrary.html.twig' %} {% block title %}ProductCategory{% endblock %} diff --git a/templates/welcome.html.twig b/templates/welcome.html.twig index f84bfe2..8c1abce 100644 --- a/templates/welcome.html.twig +++ b/templates/welcome.html.twig @@ -6,7 +6,7 @@ {% block body %} - Today is {{data}} + Today is {{ data }}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras rutrum libero et arcu aliquet luctus in vitae arcu.