<?php
namespace App\Entity\Carrier;
use App\Entity\ProduitCarrier;
use App\Repository\CarrierRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use App\Entity\Order\Order;
#[ORM\Entity(repositoryClass: CarrierRepository::class)]
class Carrier implements TranslatableInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(nullable: true)]
private ?bool $isEnable = null;
use TranslatableTrait;
#[Assert\Valid]
protected $translations;
#[ORM\OneToMany(mappedBy: 'carrier', targetEntity: ProduitCarrier::class)]
private Collection $produitCarriers;
#[ORM\Column(length: 255, nullable: true)]
private ?string $country = null;
#[ORM\OneToMany(mappedBy: 'carrier', targetEntity: Order::class)]
private Collection $orders;
#[ORM\Column(nullable: true)]
private ?bool $disableCheck = null;
#[ORM\Column]
private ?bool $isFree = null;
public function __construct()
{
$this->produitCarriers = new ArrayCollection();
$this->orders = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function isIsEnable(): ?bool
{
return $this->isEnable;
}
public function setIsEnable(?bool $isEnable): static
{
$this->isEnable = $isEnable;
return $this;
}
/**
* @return Collection<int, ProduitCarrier>
*/
public function getProduitCarriers(): Collection
{
return $this->produitCarriers;
}
public function addProduitCarrier(ProduitCarrier $produitCarrier): static
{
if (!$this->produitCarriers->contains($produitCarrier)) {
$this->produitCarriers->add($produitCarrier);
$produitCarrier->setCarrier($this);
}
return $this;
}
public function removeProduitCarrier(ProduitCarrier $produitCarrier): static
{
if ($this->produitCarriers->removeElement($produitCarrier)) {
// set the owning side to null (unless already changed)
if ($produitCarrier->getCarrier() === $this) {
$produitCarrier->setCarrier(null);
}
}
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): static
{
$this->country = $country;
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): static
{
if (!$this->orders->contains($order)) {
$this->orders->add($order);
$order->setCarrier($this);
}
return $this;
}
public function removeOrder(Order $order): static
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getCarrier() === $this) {
$order->setCarrier(null);
}
}
return $this;
}
public function __toString(){
return $this->getName();
}
public function getDisableCheck(): ?bool
{
return $this->disableCheck;
}
public function setDisableCheck(?bool $disableCheck): static
{
$this->disableCheck = $disableCheck;
return $this;
}
public function isIsFree(): ?bool
{
return $this->isFree;
}
public function setIsFree(bool $isFree): static
{
$this->isFree = $isFree;
return $this;
}
}