src/Entity/Shop/Order/ShippingMethod.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Order;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Shop\Shop\Shop;
  5. use App\Repository\Shop\Order\ShippingMethodRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  11. #[ORM\Entity(repositoryClassShippingMethodRepository::class)]
  12. class ShippingMethod extends BaseEntity
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\Column(type'guid'uniquetrue)]
  16.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  17.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  18.     private ?string $id;
  19.     #[ORM\Column(length255)]
  20.     private ?string $name null;
  21.     #[ORM\Column(typeTypes::BIGINT)]
  22.     private ?string $cost null;
  23.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  24.     private ?string $description null;
  25.     #[ORM\OneToMany(mappedBy'shippingMethod'targetEntityOrder::class)]
  26.     private Collection $orders;
  27.     #[ORM\ManyToOne(inversedBy'shippingMethods')]
  28.     #[ORM\JoinColumn(nullablefalse)]
  29.     private ?Shop $shop null;
  30.     public function __toString()
  31.     {
  32.      return $this->getName().' ('.number_format($this->getCost()).' تومان '.')';
  33.     }
  34.     public function __construct()
  35.     {
  36.         parent::__construct();
  37.         $this->orders = new ArrayCollection();
  38.     }
  39.     public function getId(): ?string
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): static
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     public function getCost(): ?string
  53.     {
  54.         return $this->cost;
  55.     }
  56.     public function setCost(string $cost): static
  57.     {
  58.         $this->cost $cost;
  59.         return $this;
  60.     }
  61.     public function getDescription(): ?string
  62.     {
  63.         return $this->description;
  64.     }
  65.     public function setDescription(?string $description): static
  66.     {
  67.         $this->description $description;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection<int, Order>
  72.      */
  73.     public function getOrders(): Collection
  74.     {
  75.         return $this->orders;
  76.     }
  77.     public function addOrder(Order $order): static
  78.     {
  79.         if (!$this->orders->contains($order)) {
  80.             $this->orders->add($order);
  81.             $order->setShippingMethod($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeOrder(Order $order): static
  86.     {
  87.         if ($this->orders->removeElement($order)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($order->getShippingMethod() === $this) {
  90.                 $order->setShippingMethod(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     public function getShop(): ?Shop
  96.     {
  97.         return $this->shop;
  98.     }
  99.     public function setShop(?Shop $shop): static
  100.     {
  101.         $this->shop $shop;
  102.         return $this;
  103.     }
  104. }