src/Entity/Account/PhoneReviewAdded.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Account;
  3. use App\Entity\User;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\ORM\Mapping\UniqueConstraint;
  6. #[ORM\Table(name: 'phone_reviews_added')]
  7. #[UniqueConstraint(name: 'search_idx', columns: ['user_id', 'phone'])]
  8. #[ORM\Entity]
  9. class PhoneReviewAdded
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\Column(name: 'id', type: 'integer')]
  13.     #[ORM\GeneratedValue(strategy: 'AUTO')]
  14.     protected int $id;
  15.     #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
  16.     #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'phoneReviewsAdded')]
  17.     protected User $user;
  18.     #[ORM\Column(type: 'string')]
  19.     protected string $phone;
  20.     #[ORM\Column(name: 'created_at', type: 'datetimetz_immutable', options: ['default' => 'CURRENT_TIMESTAMP'])]
  21.     protected \DateTimeImmutable $createdAt;
  22.     public function __construct(User $user, string $phone)
  23.     {
  24.         $this->user = $user;
  25.         $this->phone = $phone;
  26.         $this->createdAt = new \DateTimeImmutable('now');
  27.     }
  28.     public function getId(): int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getUser(): User
  33.     {
  34.         return $this->user;
  35.     }
  36.     public function setUser(User $user): void
  37.     {
  38.         $this->user = $user;
  39.     }
  40.     public function getPhone(): string
  41.     {
  42.         return $this->phone;
  43.     }
  44.     public function setPhone(string $phone): void
  45.     {
  46.         $this->phone = $phone;
  47.     }
  48.     public function getCreatedAt(): \DateTimeImmutable
  49.     {
  50.         return $this->createdAt;
  51.     }
  52.     public function setCreatedAt(\DateTimeImmutable $createdAt): void
  53.     {
  54.         $this->createdAt = $createdAt;
  55.     }
  56. }