src/Entity/Profile/ProfileName.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Profile;
  3. use App\Entity\Location\City;
  4. use App\Repository\ProfileNameRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Mapping\UniqueConstraint;
  9. #[ORM\Table(name: 'profile_names')]
  10. #[UniqueConstraint(name: 'profile_name_city_uri_unique', columns: ['city_id', 'uri_identity'])]
  11. #[ORM\Index(name: 'IDX_PROFILE_NAME_CITY_COUNT', columns: ['city_id', 'active_profiles_count'])]
  12. #[ORM\Entity(repositoryClass: ProfileNameRepository::class)]
  13. class ProfileName
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\Column(type: 'integer')]
  17.     #[ORM\GeneratedValue(strategy: 'AUTO')]
  18.     private int $id;
  19.     #[ORM\ManyToOne(targetEntity: City::class)]
  20.     #[ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
  21.     private City $city;
  22.     #[ORM\Column(name: 'canonical_name', type: 'string', length: 255)]
  23.     private string $canonicalName;
  24.     #[ORM\Column(name: 'heading_name', type: 'string', length: 255)]
  25.     private string $headingName;
  26.     #[ORM\Column(name: 'first_letter', type: 'string', length: 8)]
  27.     private string $firstLetter;
  28.     #[ORM\Column(name: 'uri_identity', type: 'string', length: 255)]
  29.     private string $uriIdentity;
  30.     #[ORM\Column(name: 'active_profiles_count', type: 'integer', options: ['default' => 0])]
  31.     private int $activeProfilesCount = 0;
  32.     #[ORM\ManyToMany(targetEntity: Profile::class, mappedBy: 'profileNames')]
  33.     private Collection $profiles;
  34.     public function __construct(
  35.         City $city,
  36.         string $canonicalName,
  37.         string $headingName,
  38.         string $firstLetter,
  39.         string $uriIdentity
  40.     ) {
  41.         $this->city = $city;
  42.         $this->canonicalName = $canonicalName;
  43.         $this->headingName = $headingName;
  44.         $this->firstLetter = $firstLetter;
  45.         $this->uriIdentity = $uriIdentity;
  46.         $this->profiles = new ArrayCollection();
  47.     }
  48.     public function getId(): int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getCity(): City
  53.     {
  54.         return $this->city;
  55.     }
  56.     public function getCanonicalName(): string
  57.     {
  58.         return $this->canonicalName;
  59.     }
  60.     public function getFirstLetter(): string
  61.     {
  62.         return $this->firstLetter;
  63.     }
  64.     public function getHeadingName(): string
  65.     {
  66.         return $this->headingName;
  67.     }
  68.     public function getUriIdentity(): string
  69.     {
  70.         return $this->uriIdentity;
  71.     }
  72.     public function getActiveProfilesCount(): int
  73.     {
  74.         return $this->activeProfilesCount;
  75.     }
  76. }