src/Flexy/ShopBundle/Entity/Shipping/Vehicle/ShippingVehicleType.php line 16

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping\Vehicle;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod;
  5. use App\Flexy\ShopBundle\Repository\Shipping\ShippingVehicleTypeRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. #[ApiResource]
  11. #[ORM\Entity(repositoryClassShippingVehicleTypeRepository::class)]
  12. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  13. class ShippingVehicleType implements \Stringable
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  20.     private $createdAt;
  21.      #[ORM\Column(type'string'length255nullabletrue)]
  22.     private $name;
  23.          #[ORM\Column(type'string'length255nullabletrue)]
  24.     private $icon;
  25.    #[ORM\OneToMany(targetEntityShippingMethod::class, mappedBy'shippingVehicleType')]
  26.     private \Doctrine\Common\Collections\Collection|array $shippingMethods ;
  27.    #[ORM\OneToMany(mappedBy'shippingVehicleType'targetEntityShippingVehicle::class,cascade:["remove"])]
  28.    private Collection $shippingVehicles;
  29.    #[ORM\Column(nullabletrue)]
  30.    private ?\DateTimeImmutable $deletedAt null;
  31.     public function __construct()
  32.     {
  33.         $this->shippingMethods = new ArrayCollection();
  34.         $this->shippingVehicles = new ArrayCollection();
  35.     }
  36.     public function __toString(): string
  37.     {
  38.         return (string)$this->name;
  39.     }
  40.     /**
  41.      * Get the value of id
  42.      */ 
  43.     public function getId()
  44.     {
  45.         return $this->id;
  46.     }
  47.     /**
  48.      * Get the value of createdAt
  49.      */ 
  50.     public function getCreatedAt()
  51.     {
  52.         return $this->createdAt;
  53.     }
  54.     /**
  55.      * Set the value of createdAt
  56.      *
  57.      * @return  self
  58.      */ 
  59.     public function setCreatedAt($createdAt)
  60.     {
  61.         $this->createdAt $createdAt;
  62.         return $this;
  63.     }
  64.     /**
  65.      * Get the value of name
  66.      */ 
  67.     public function getName()
  68.     {
  69.         return $this->name;
  70.     }
  71.     /**
  72.      * Set the value of name
  73.      *
  74.      * @return  self
  75.      */ 
  76.     public function setName($name)
  77.     {
  78.         $this->name $name;
  79.         return $this;
  80.     }
  81.         /**
  82.      * @return Collection<int, CityRegion>
  83.      */
  84.     public function getShippingMethods(): Collection
  85.     {
  86.         return $this->shippingMethods;
  87.     }
  88.     public function addShippingMethod(ShippingMethod $shippingMethod): self
  89.     {
  90.         if (!$this->shippingMethods->contains($shippingMethod)) {
  91.             $this->shippingMethods[] = $shippingMethod;
  92.             $shippingMethod->setShippingVehicleType($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeShippingMethod(ShippingMethod $shippingMethod): self
  97.     {
  98.         if ($this->shippingMethods->removeElement($shippingMethod)) {
  99.             $shippingMethod->setShippingVehicleType(null);
  100.         }
  101.         return $this;
  102.     }
  103.     /**
  104.      * Get the value of icon
  105.      */ 
  106.     public function getIcon()
  107.     {
  108.         return $this->icon;
  109.     }
  110.     /**
  111.      * Set the value of icon
  112.      *
  113.      * @return  self
  114.      */ 
  115.     public function setIcon($icon)
  116.     {
  117.         $this->icon $icon;
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, ShippingVehicle>
  122.      */
  123.     public function getShippingVehicles(): Collection
  124.     {
  125.         return $this->shippingVehicles;
  126.     }
  127.     public function addShippingVehicle(ShippingVehicle $shippingVehicle): self
  128.     {
  129.         if (!$this->shippingVehicles->contains($shippingVehicle)) {
  130.             $this->shippingVehicles->add($shippingVehicle);
  131.             $shippingVehicle->setShippingVehicleType($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeShippingVehicle(ShippingVehicle $shippingVehicle): self
  136.     {
  137.         if ($this->shippingVehicles->removeElement($shippingVehicle)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($shippingVehicle->getShippingVehicleType() === $this) {
  140.                 $shippingVehicle->setShippingVehicleType(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.    /**
  146.     * Get the value of deletedAt
  147.     */ 
  148.    public function getDeletedAt()
  149.    {
  150.       return $this->deletedAt;
  151.    }
  152.    /**
  153.     * Set the value of deletedAt
  154.     *
  155.     * @return  self
  156.     */ 
  157.    public function setDeletedAt($deletedAt)
  158.    {
  159.       $this->deletedAt $deletedAt;
  160.       return $this;
  161.    }
  162. }