src/Entity/City.php line 32
<?php
namespace App\Entity;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Patch;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\CityRepository;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: CityRepository::class)]
#[ApiResource(
operations: [
new GetCollection(
normalizationContext: [
'groups' => [self::SERIALIZATION_GROUP__FULL_DATA],
]
),
new Patch(),
new Post(),
]
)]
#[ApiFilter(SearchFilter::class, properties: [self::NAME_PARAM_NAME => 'exact'])]
/**
* Contains City model.
*/
class City
{
public const SERIALIZATION_GROUP__FULL_DATA = 'city_full_data';
public const NAME_PARAM_NAME = 'name';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups([self::SERIALIZATION_GROUP__FULL_DATA])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups([self::SERIALIZATION_GROUP__FULL_DATA])]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups([self::SERIALIZATION_GROUP__FULL_DATA])]
private ?string $country = null;
#[ORM\OneToOne(inversedBy: 'city', targetEntity: LivingCostStatistics::class, cascade: ['persist', 'remove'])]
#[Groups([self::SERIALIZATION_GROUP__FULL_DATA])]
private ?LivingCostStatistics $livingCostStatistics = null;
/**
* Gets Id.
*
* @return integer|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
*
* @return self
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getCountry(): ?string
{
return $this->country;
}
/**
* @param string|null $country
*
* @return self
*/
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
/**
* @return LivingCostStatistics|null
*/
public function getLivingCostStatistics(): ?LivingCostStatistics
{
return $this->livingCostStatistics;
}
/**
* Sets relation to LivingCostStatistics entity.
*
* @param LivingCostStatistics|null $livingCostStatistics
*
* @return self
*/
public function setLivingCostStatistics(?LivingCostStatistics $livingCostStatistics): self
{
$this->livingCostStatistics = $livingCostStatistics;
return $this;
}
}