Commit 6c9559e6 authored by Александр Плохих's avatar Александр Плохих 🌔
Browse files

STA-960 | fix repo & entity & some small fixes

parent 81d4641c
Loading
Loading
Loading
Loading
+96 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20240427114630 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE kitchens (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE news (id UUID NOT NULL, type_id UUID DEFAULT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, sort INT NOT NULL, active BOOLEAN NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, preview_image VARCHAR(255) DEFAULT NULL, preview_text VARCHAR(1000) DEFAULT NULL, detail_image VARCHAR(255) DEFAULT NULL, detail_text VARCHAR(255) DEFAULT NULL, main_page_render BOOLEAN NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_1DD39950C54C8C93 ON news (type_id)');
        $this->addSql('COMMENT ON COLUMN news.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN news.update_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE TABLE news_news_categories (news_id UUID NOT NULL, news_categories_id UUID NOT NULL, PRIMARY KEY(news_id, news_categories_id))');
        $this->addSql('CREATE INDEX IDX_34AB0102B5A459A0 ON news_news_categories (news_id)');
        $this->addSql('CREATE INDEX IDX_34AB0102F7F178F1 ON news_news_categories (news_categories_id)');
        $this->addSql('CREATE TABLE news_categories (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE news_type (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE restaurant_types (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE TABLE restaurants (id UUID NOT NULL, type_id UUID DEFAULT NULL, settlement_id UUID DEFAULT NULL, active BOOLEAN NOT NULL, sort INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, receipt VARCHAR(255) NOT NULL, receipt_info VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, tags VARCHAR(255) NOT NULL, site VARCHAR(255) NOT NULL, coordinates TEXT NOT NULL, preview_image VARCHAR(255) NOT NULL, detail_image VARCHAR(255) NOT NULL, gallery VARCHAR(255) NOT NULL, how_to_find VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_AD837724C54C8C93 ON restaurants (type_id)');
        $this->addSql('CREATE INDEX IDX_AD837724C2B9C425 ON restaurants (settlement_id)');
        $this->addSql('COMMENT ON COLUMN restaurants.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN restaurants.update_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN restaurants.coordinates IS \'(DC2Type:array)\'');
        $this->addSql('CREATE TABLE restaurants_kitchens (restaurants_id UUID NOT NULL, kitchens_id UUID NOT NULL, PRIMARY KEY(restaurants_id, kitchens_id))');
        $this->addSql('CREATE INDEX IDX_716464694DCA160A ON restaurants_kitchens (restaurants_id)');
        $this->addSql('CREATE INDEX IDX_71646469E043FCBC ON restaurants_kitchens (kitchens_id)');
        $this->addSql('CREATE TABLE settlements (id UUID NOT NULL, active BOOLEAN NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, coordinates TEXT NOT NULL, PRIMARY KEY(id))');
        $this->addSql('COMMENT ON COLUMN settlements.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN settlements.update_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN settlements.coordinates IS \'(DC2Type:array)\'');
        $this->addSql('CREATE TABLE users (id UUID NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, is_male BOOLEAN NOT NULL, address VARCHAR(255) NOT NULL, birthday DATE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('COMMENT ON COLUMN users.birthday IS \'(DC2Type:date_immutable)\'');
        $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 news ADD CONSTRAINT FK_1DD39950C54C8C93 FOREIGN KEY (type_id) REFERENCES news_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE news_news_categories ADD CONSTRAINT FK_34AB0102B5A459A0 FOREIGN KEY (news_id) REFERENCES news (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE news_news_categories ADD CONSTRAINT FK_34AB0102F7F178F1 FOREIGN KEY (news_categories_id) REFERENCES news_categories (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants ADD CONSTRAINT FK_AD837724C54C8C93 FOREIGN KEY (type_id) REFERENCES restaurant_types (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants ADD CONSTRAINT FK_AD837724C2B9C425 FOREIGN KEY (settlement_id) REFERENCES settlements (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants_kitchens ADD CONSTRAINT FK_716464694DCA160A FOREIGN KEY (restaurants_id) REFERENCES restaurants (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE restaurants_kitchens ADD CONSTRAINT FK_71646469E043FCBC FOREIGN KEY (kitchens_id) REFERENCES kitchens (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 news DROP CONSTRAINT FK_1DD39950C54C8C93');
        $this->addSql('ALTER TABLE news_news_categories DROP CONSTRAINT FK_34AB0102B5A459A0');
        $this->addSql('ALTER TABLE news_news_categories DROP CONSTRAINT FK_34AB0102F7F178F1');
        $this->addSql('ALTER TABLE restaurants DROP CONSTRAINT FK_AD837724C54C8C93');
        $this->addSql('ALTER TABLE restaurants DROP CONSTRAINT FK_AD837724C2B9C425');
        $this->addSql('ALTER TABLE restaurants_kitchens DROP CONSTRAINT FK_716464694DCA160A');
        $this->addSql('ALTER TABLE restaurants_kitchens DROP CONSTRAINT FK_71646469E043FCBC');
        $this->addSql('DROP TABLE kitchens');
        $this->addSql('DROP TABLE news');
        $this->addSql('DROP TABLE news_news_categories');
        $this->addSql('DROP TABLE news_categories');
        $this->addSql('DROP TABLE news_type');
        $this->addSql('DROP TABLE restaurant_types');
        $this->addSql('DROP TABLE restaurants');
        $this->addSql('DROP TABLE restaurants_kitchens');
        $this->addSql('DROP TABLE settlements');
        $this->addSql('DROP TABLE users');
        $this->addSql('DROP TABLE messenger_messages');
    }
}
+20 −0
Original line number Diff line number Diff line
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class RestaurantsController extends AbstractController
{
    /***
     * Листинг ресторанов
     * @return Response
     */
    #[Route('/restaurants/', name: 'restaurants')]
    public function restaurants(): Response
    {

    }
}
+10 −0
Original line number Diff line number Diff line
<?php

namespace App\DTO;

class RestaurantListDTO
{
    private $pagination;
    private $list;
    private $filterVariants;
}
 No newline at end of file
+15 −0
Original line number Diff line number Diff line
<?php

namespace App\DTO;

class RestaurantListingElementDTO
{
    private $id;
    private $name;
    private $code;
    private $type;
    private $check;
    private $image;
    private $detailLink;

}
 No newline at end of file
+291 −0
Original line number Diff line number Diff line
<?php

namespace App\Entity;

use App\Repository\FileRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: FileRepository::class)]
class File
{
    #[ORM\Id]
    #[ORM\Column(type: Types::GUID)]
    private ?string $id = null;

    #[ORM\Column(length: 255)]
    private ?string $name = null;

    #[ORM\Column(length: 255)]
    private ?string $description = null;

    #[ORM\Column]
    private ?int $size = null;

    #[ORM\Column(length: 255)]
    private ?string $type = null;

    #[ORM\Column(length: 255)]
    private ?string $url = null;

    /**
     * @var Collection<int, Restaurants>
     */
    #[ORM\OneToMany(targetEntity: Restaurants::class, mappedBy: 'previewImage')]
    private Collection $restaurantsPreview;

    /**
     * @var Collection<int, Restaurants>
     */
    #[ORM\OneToMany(targetEntity: Restaurants::class, mappedBy: 'detailImage')]
    private Collection $restaurantsDetail;

    /**
     * @var Collection<int, Restaurants>
     */
    #[ORM\ManyToMany(targetEntity: Restaurants::class, mappedBy: 'gallery')]
    private Collection $restaurantsGallery;

    /**
     * @var Collection<int, News>
     */
    #[ORM\OneToMany(targetEntity: News::class, mappedBy: 'detailImage')]

    private Collection $newsDetail;

    /**
     * @var Collection<int, News>
     */
    #[ORM\OneToMany(targetEntity: News::class, mappedBy: 'previewImage')]
    private Collection $newsPreview;

    public function __construct()
    {
        $this->restaurantsPreview = new ArrayCollection();
        $this->restaurantsDetail = new ArrayCollection();
        $this->restaurantsGallery = new ArrayCollection();
        $this->newsDetail = new ArrayCollection();
        $this->newsPreview = new ArrayCollection();
    }

    public function getId(): ?string
    {
        return $this->id;
    }

    public function setId(string $id): static
    {
        $this->id = $id;

        return $this;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): static
    {
        $this->name = $name;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(string $description): static
    {
        $this->description = $description;

        return $this;
    }

    public function getSize(): ?int
    {
        return $this->size;
    }

    public function setSize(int $size): static
    {
        $this->size = $size;

        return $this;
    }

    public function getType(): ?string
    {
        return $this->type;
    }

    public function setType(string $type): static
    {
        $this->type = $type;

        return $this;
    }

    public function getUrl(): ?string
    {
        return $this->url;
    }

    public function setUrl(string $url): static
    {
        $this->url = $url;

        return $this;
    }

    /**
     * @return Collection<int, Restaurants>
     */
    public function getRestaurantsPreview(): Collection
    {
        return $this->restaurantsPreview;
    }

    public function addRestaurantsPreview(Restaurants $restaurantsPreview): static
    {
        if (!$this->restaurantsPreview->contains($restaurantsPreview)) {
            $this->restaurantsPreview->add($restaurantsPreview);
            $restaurantsPreview->setPreviewImage($this);
        }

        return $this;
    }

    public function removeRestaurantsPreview(Restaurants $restaurantsPreview): static
    {
        if ($this->restaurantsPreview->removeElement($restaurantsPreview)) {
            // set the owning side to null (unless already changed)
            if ($restaurantsPreview->getPreviewImage() === $this) {
                $restaurantsPreview->setPreviewImage(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Restaurants>
     */
    public function getRestaurantsDetail(): Collection
    {
        return $this->restaurantsDetail;
    }

    public function addRestaurantsDetail(Restaurants $restaurantsDetail): static
    {
        if (!$this->restaurantsDetail->contains($restaurantsDetail)) {
            $this->restaurantsDetail->add($restaurantsDetail);
            $restaurantsDetail->setDetailImage($this);
        }

        return $this;
    }

    public function removeRestaurantsDetail(Restaurants $restaurantsDetail): static
    {
        if ($this->restaurantsDetail->removeElement($restaurantsDetail)) {
            // set the owning side to null (unless already changed)
            if ($restaurantsDetail->getDetailImage() === $this) {
                $restaurantsDetail->setDetailImage(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, Restaurants>
     */
    public function getRestaurantsGallery(): Collection
    {
        return $this->restaurantsGallery;
    }

    public function addRestaurantsGallery(Restaurants $restaurantsGallery): static
    {
        if (!$this->restaurantsGallery->contains($restaurantsGallery)) {
            $this->restaurantsGallery->add($restaurantsGallery);
            $restaurantsGallery->addGallery($this);
        }

        return $this;
    }

    public function removeRestaurantsGallery(Restaurants $restaurantsGallery): static
    {
        if ($this->restaurantsGallery->removeElement($restaurantsGallery)) {
            $restaurantsGallery->removeGallery($this);
        }

        return $this;
    }

    /**
     * @return Collection<int, News>
     */
    public function getNewsDetail(): Collection
    {
        return $this->newsDetail;
    }

    public function addNewsDetail(News $newsDetail): static
    {
        if (!$this->newsDetail->contains($newsDetail)) {
            $this->newsDetail->add($newsDetail);
            $newsDetail->setDetailImage($this);
        }

        return $this;
    }

    public function removeNewsDetail(News $newsDetail): static
    {
        if ($this->newsDetail->removeElement($newsDetail)) {
            // set the owning side to null (unless already changed)
            if ($newsDetail->getDetailImage() === $this) {
                $newsDetail->setDetailImage(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, News>
     */
    public function getNewsPreview(): Collection
    {
        return $this->newsPreview;
    }

    public function addNewsPreview(News $newsPreview): static
    {
        if (!$this->newsPreview->contains($newsPreview)) {
            $this->newsPreview->add($newsPreview);
            $newsPreview->setPreviewImage($this);
        }

        return $this;
    }

    public function removeNewsPreview(News $newsPreview): static
    {
        if ($this->newsPreview->removeElement($newsPreview)) {
            // set the owning side to null (unless already changed)
            if ($newsPreview->getPreviewImage() === $this) {
                $newsPreview->setPreviewImage(null);
            }
        }

        return $this;
    }
}
Loading