src/Entity/Location/Subway/Line.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Location\Subway;
  3. use App\Entity\Location\City;
  4. use App\Repository\StationRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\ORM\Mapping\UniqueConstraint;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. #[ORM\Table(name: 'city_subway_lines')]
  9. #[UniqueConstraint(name: 'subway_lines_unique_city_name', columns: ['city_id', 'name'])]
  10. #[ORM\Entity(repositoryClass: StationRepository::class)]
  11. #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'geoposition')]
  12. class Line
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\Column(name: 'id', type: 'integer')]
  16.     #[ORM\GeneratedValue(strategy: 'AUTO')]
  17.     #[Groups('profile', 'listing')]
  18.     protected int $id;
  19.     #[ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id')]
  20.     #[ORM\ManyToOne(targetEntity: City::class)]
  21.     #[ORM\Cache(usage: 'READ_ONLY', region: 'geoposition')]
  22.     protected City $city;
  23.     #[ORM\Column(name: 'name', type: 'string')]
  24.     #[Groups('profile', 'listing')]
  25.     protected string $name;
  26.     #[ORM\Column(name: 'color', type: 'string')]
  27.     #[Groups('profile', 'listing')]
  28.     protected string $color;
  29.     public function __construct(
  30.         City $city, string $name, string $color
  31.     )
  32.     {
  33.         $this->city = $city;
  34.         $this->name = $name;
  35.         $this->color = $color;
  36.     }
  37.     public function id(): int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function name(): string
  42.     {
  43.         return $this->name;
  44.     }
  45.     public function color(): string
  46.     {
  47.         return $this->color;
  48.     }
  49. }