src/Entity/Airline.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AirlineRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassAirlineRepository::class)]
  10. #[UniqueEntity(['iataCode'])]
  11. class Airline
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length2,  uniquetrue)]
  18.     #[Assert\NotBlank]
  19.     #[Assert\length(max2)]
  20.     public ?string $iataCodenull;
  21.     #[ORM\Column(length255)]
  22.     private ?string $businessName null;
  23.     #[ORM\Column(length3uniquetruenullabletrue)]
  24.     #[Assert\length(max3)]
  25.     private ?string $icaoCode null;
  26.     #[ORM\Column(length255)]
  27.     private ?string $commonName null;
  28.     #[ORM\OneToMany(mappedBy'airline'targetEntityAirlineXmlApi::class, orphanRemovaltrue)]
  29.     private Collection $airlineXmlApis;
  30.     #[ORM\OneToOne(inversedBy'airline'cascade: ['persist''remove'])]
  31.     private ?FileData $logo null;
  32.     #[ORM\ManyToMany(targetEntityCountry::class)]
  33.     #[ORM\JoinTable(name'airline_accessible_country')]
  34.     private Collection $accessibleCountries;
  35.     public function __construct()
  36.     {
  37.         $this->airlineXmlApis = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getIataCode(): ?string
  44.     {
  45.         return $this->iataCode;
  46.     }
  47.     public function setIataCode(string $iataCode): self
  48.     {
  49.         $this->iataCode $iataCode;
  50.         return $this;
  51.     }
  52.     public function getBusinessName(): ?string
  53.     {
  54.         return $this->businessName;
  55.     }
  56.     public function setBusinessName(string $businessName): self
  57.     {
  58.         $this->businessName $businessName;
  59.         return $this;
  60.     }
  61.     public function getIcaoCode(): ?string
  62.     {
  63.         return $this->icaoCode;
  64.     }
  65.     public function setIcaoCode(string $icaoCode): self
  66.     {
  67.         $this->icaoCode $icaoCode;
  68.         return $this;
  69.     }
  70.     public function getCommonName(): ?string
  71.     {
  72.         return $this->commonName;
  73.     }
  74.     public function setCommonName(string $commonName): self
  75.     {
  76.         $this->commonName $commonName;
  77.         return $this;
  78.     }
  79.     public function __toString(){
  80.             return $this->getIataCode() . ' : ' $this->getBusinessName() . " - " $this->getCommonName();
  81.     }
  82.     /**
  83.      * @return Collection<int, AirlineXmlApi>
  84.      */
  85.     public function getAirlineXmlApis(): Collection
  86.     {
  87.         return $this->airlineXmlApis;
  88.     }
  89.     public function addAirlineXmlApi(AirlineXmlApi $airlineXmlApi): static
  90.     {
  91.         if (!$this->airlineXmlApis->contains($airlineXmlApi)) {
  92.             $this->airlineXmlApis->add($airlineXmlApi);
  93.             $airlineXmlApi->setAirline($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeAirlineXmlApi(AirlineXmlApi $airlineXmlApi): static
  98.     {
  99.         if ($this->airlineXmlApis->removeElement($airlineXmlApi)) {
  100.             // set the owning side to null (unless already changed)
  101.             if ($airlineXmlApi->getAirline() === $this) {
  102.                 $airlineXmlApi->setAirline(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     public function getLogo(): ?FileData
  108.     {
  109.         return $this->logo;
  110.     }
  111.     public function setLogo(?FileData $logo): static
  112.     {
  113.         $this->logo $logo;
  114.         return $this;
  115.     }
  116.     public function getAccessibleCountries(): Collection
  117.     {
  118.         return $this->accessibleCountries;
  119.     }
  120.     public function addAccessibleCountry(Country $country): static
  121.     {
  122.         if (!$this->accessibleCountries->contains($country)) {
  123.             $this->accessibleCountries->add($country);
  124.         }
  125.         return $this;
  126.     }
  127.     public function removeAccessibleCountry(Country $country): static
  128.     {
  129.         $this->accessibleCountries->removeElement($country);
  130.         return $this;
  131.     }
  132. }