src/Flexy/ShopBundle/Entity/Shipping/Vehicle/ShippingVehicleType.php line 16
<?php
namespace App\Flexy\ShopBundle\Entity\Shipping\Vehicle;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod;
use App\Flexy\ShopBundle\Repository\Shipping\ShippingVehicleTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
#[ApiResource]
#[ORM\Entity(repositoryClass: ShippingVehicleTypeRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
class ShippingVehicleType implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private $createdAt;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $icon;
#[ORM\OneToMany(targetEntity: ShippingMethod::class, mappedBy: 'shippingVehicleType')]
private \Doctrine\Common\Collections\Collection|array $shippingMethods ;
#[ORM\OneToMany(mappedBy: 'shippingVehicleType', targetEntity: ShippingVehicle::class,cascade:["remove"])]
private Collection $shippingVehicles;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $deletedAt = null;
public function __construct()
{
$this->shippingMethods = new ArrayCollection();
$this->shippingVehicles = new ArrayCollection();
}
public function __toString(): string
{
return (string)$this->name;
}
/**
* Get the value of id
*/
public function getId()
{
return $this->id;
}
/**
* Get the value of createdAt
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set the value of createdAt
*
* @return self
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get the value of name
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, CityRegion>
*/
public function getShippingMethods(): Collection
{
return $this->shippingMethods;
}
public function addShippingMethod(ShippingMethod $shippingMethod): self
{
if (!$this->shippingMethods->contains($shippingMethod)) {
$this->shippingMethods[] = $shippingMethod;
$shippingMethod->setShippingVehicleType($this);
}
return $this;
}
public function removeShippingMethod(ShippingMethod $shippingMethod): self
{
if ($this->shippingMethods->removeElement($shippingMethod)) {
$shippingMethod->setShippingVehicleType(null);
}
return $this;
}
/**
* Get the value of icon
*/
public function getIcon()
{
return $this->icon;
}
/**
* Set the value of icon
*
* @return self
*/
public function setIcon($icon)
{
$this->icon = $icon;
return $this;
}
/**
* @return Collection<int, ShippingVehicle>
*/
public function getShippingVehicles(): Collection
{
return $this->shippingVehicles;
}
public function addShippingVehicle(ShippingVehicle $shippingVehicle): self
{
if (!$this->shippingVehicles->contains($shippingVehicle)) {
$this->shippingVehicles->add($shippingVehicle);
$shippingVehicle->setShippingVehicleType($this);
}
return $this;
}
public function removeShippingVehicle(ShippingVehicle $shippingVehicle): self
{
if ($this->shippingVehicles->removeElement($shippingVehicle)) {
// set the owning side to null (unless already changed)
if ($shippingVehicle->getShippingVehicleType() === $this) {
$shippingVehicle->setShippingVehicleType(null);
}
}
return $this;
}
/**
* Get the value of deletedAt
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set the value of deletedAt
*
* @return self
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
}