src/Entity/Profile/Comment/Comment.php line 22

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