src/Entity/Saloon/Comment/Comment.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Saloon\Comment;
  3. use App\Entity\Saloon\Saloon;
  4. use App\Entity\System\IpAddress;
  5. use App\Entity\User;
  6. use App\Repository\SaloonCommentRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  9. #[ORM\Table(name'saloon_comments')]
  10. #[ORM\Entity(repositoryClassSaloonCommentRepository::class)]
  11. #[ORM\InheritanceType('SINGLE_TABLE')]
  12. #[ORM\DiscriminatorColumn(name'account_type'type'string'length12)]
  13. #[ORM\DiscriminatorMap(['customer' => CommentByCustomer::class, 'advertiser' => CommentByAdvertiser::class, 'support' => CommentBySupport::class])]
  14. abstract class Comment
  15. {
  16.     use SoftDeleteableEntity;
  17.     #[ORM\Id]
  18.     #[ORM\Column(name'id'type'integer')]
  19.     #[ORM\GeneratedValue(strategy'AUTO')]
  20.     protected int $id;
  21.     #[ORM\JoinColumn(name'parent_id'referencedColumnName'id'nullabletrue)]
  22.     #[ORM\ManyToOne(targetEntityComment::class)]
  23.     protected ?Comment $parent;
  24.     //, inversedBy="comments"
  25.     #[ORM\JoinColumn(name'saloon_id'referencedColumnName'id'nullabletrue)]
  26.     #[ORM\ManyToOne(targetEntitySaloon::class, inversedBy'comments')]
  27.     protected ?Saloon $saloon;
  28.     #[ORM\JoinColumn(name'user_id'referencedColumnName'id'nullabletrue)]
  29.     #[ORM\ManyToOne(targetEntityUser::class)]
  30.     protected ?User $user;
  31.     #[ORM\Column(name'text'type'text')]
  32.     protected string $text;
  33.     #[ORM\Column(name'created_at'type'datetimetz_immutable')]
  34.     protected \DateTimeImmutable $createdAt;
  35.     #[ORM\JoinColumn(name'ip_address_id'referencedColumnName'id')]
  36.     #[ORM\ManyToOne(targetEntityIpAddress::class, inversedBy'saloonComments')]
  37.     protected ?IpAddress $ipAddress;
  38.     public function __construct(Saloon $saloon, ?Comment $parent, ?User $userstring $text\DateTimeImmutable $createdAt)
  39.     {
  40.         $this->parent $parent;
  41.         $this->saloon $saloon;
  42.         $this->user $user;
  43.         $this->text $text;
  44.         $this->createdAt $createdAt;
  45.     }
  46.     public function getId(): int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getParent(): ?Comment
  51.     {
  52.         return $this->parent;
  53.     }
  54.     public function getUser(): ?User
  55.     {
  56.         return $this->user;
  57.     }
  58.     public function getSaloon(): ?Saloon
  59.     {
  60.         return $this->saloon;
  61.     }
  62.     public function getText(): string
  63.     {
  64.         return $this->text;
  65.     }
  66.     public function setText(string $text): void
  67.     {
  68.         $this->text $text;
  69.     }
  70.     public function getCreatedAt(): \DateTimeImmutable
  71.     {
  72.         return $this->createdAt;
  73.     }
  74.     public function setCreatedAt(\DateTimeImmutable $createdAt): void
  75.     {
  76.         $this->createdAt $createdAt;
  77.     }
  78.     public function clearRelations(): void
  79.     {
  80.         $this->saloon null;
  81.         $this->user null;
  82.     }
  83.     public function getIpAddress(): ?IpAddress
  84.     {
  85.         return $this->ipAddress;
  86.     }
  87. }