<?php
namespace App\Entity\Profile;
use App\Entity\Location\City;
use App\Repository\ProfileNameRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
#[ORM\Table(name: 'profile_names')]
#[UniqueConstraint(name: 'profile_name_city_uri_unique', columns: ['city_id', 'uri_identity'])]
#[ORM\Index(name: 'IDX_PROFILE_NAME_CITY_COUNT', columns: ['city_id', 'active_profiles_count'])]
#[ORM\Entity(repositoryClass: ProfileNameRepository::class)]
class ProfileName
{
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;
#[ORM\ManyToOne(targetEntity: City::class)]
#[ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
private City $city;
#[ORM\Column(name: 'canonical_name', type: 'string', length: 255)]
private string $canonicalName;
#[ORM\Column(name: 'heading_name', type: 'string', length: 255)]
private string $headingName;
#[ORM\Column(name: 'first_letter', type: 'string', length: 8)]
private string $firstLetter;
#[ORM\Column(name: 'uri_identity', type: 'string', length: 255)]
private string $uriIdentity;
#[ORM\Column(name: 'active_profiles_count', type: 'integer', options: ['default' => 0])]
private int $activeProfilesCount = 0;
#[ORM\ManyToMany(targetEntity: Profile::class, mappedBy: 'profileNames')]
private Collection $profiles;
public function __construct(
City $city,
string $canonicalName,
string $headingName,
string $firstLetter,
string $uriIdentity
) {
$this->city = $city;
$this->canonicalName = $canonicalName;
$this->headingName = $headingName;
$this->firstLetter = $firstLetter;
$this->uriIdentity = $uriIdentity;
$this->profiles = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function getCity(): City
{
return $this->city;
}
public function getCanonicalName(): string
{
return $this->canonicalName;
}
public function getFirstLetter(): string
{
return $this->firstLetter;
}
public function getHeadingName(): string
{
return $this->headingName;
}
public function getUriIdentity(): string
{
return $this->uriIdentity;
}
public function getActiveProfilesCount(): int
{
return $this->activeProfilesCount;
}
}