Created
March 31, 2024 21:01
-
-
Save evgeniy123/b28cb758aba881dae59e89cf9b34f4ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DeliveryMethod implements AggregateRoot | |
| { | |
| use EventsTrait; | |
| use PropertiesDateUpdateCreateTrait; | |
| #[ORM\Column(type: "delivery_method_id")] | |
| #[ORM\Id] | |
| private $id; | |
| #[ORM\Column(type: 'string', length: 255, nullable: false)] | |
| private $name; | |
| #[ORM\OneToMany(targetEntity: ShopMethodDelivery::class, mappedBy: 'deliveryMethod')] | |
| private $shopMethodDelivery; | |
| .... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .... | |
| $shop_1->attachMethodDeliveryForShop($deliveryMethodEatIn); | |
| .... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[ORM\Entity()] | |
| #[ORM\Table(name: 'shop')] | |
| #[Index(name: "shop_idx", columns: ["id"])] | |
| class Shop implements AggregateRoot | |
| { | |
| #[ORM\Column(type: "shop_id")] | |
| #[ORM\Id] | |
| private $id; | |
| #[ORM\ManyToMany(targetEntity: ShopMethodDelivery::class, mappedBy: 'shop', cascade: ['persist'], orphanRemoval: true)] | |
| private Collection $shopMethodDelivery; | |
| .... | |
| ... | |
| public function attachMethodDeliveryForShop(DeliveryMethod $deliveryMethod): static | |
| { | |
| if (!$this->shopMethodDelivery->contains($deliveryMethod)) { | |
| $this->shopMethodDelivery->add($deliveryMethod); | |
| $deliveryMethod->setShop($this); | |
| } | |
| return $this; | |
| } | |
| .... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ShopMethodDelivery implements AggregateRoot | |
| { | |
| #[ORM\Column(type: "shop_method_delivery_id")] | |
| #[ORM\Id] | |
| private $id; | |
| #[ORM\ManyToMany(targetEntity: Shop::class, inversedBy: 'shopMethodDelivery')] | |
| private $shop; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment