src/Entity/UserArticle.php line 18

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Entity\User as SuluUser;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Mapping\UniqueConstraint;
  9. use JMS\Serializer\Annotation as Serializer;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. #[ORM\Entity]
  12. #[ORM\Table(name'jm_user_article')]
  13. #[UniqueConstraint(name'user_article_unique'columns: ['user_id''article_identifier'])]
  14. class UserArticle
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\ManyToOne(targetEntitySuluUser::class, inversedBy'articles')]
  21.     private UserInterface $user;
  22.     #[ORM\Column(type'string'length192)]
  23.     #[Serializer\Groups(['profile'])]
  24.     private string $articleIdentifier '';
  25.     #[ORM\OneToMany(targetEntityUserArticlePayment::class, mappedBy'userArticle')]
  26.     private Collection $payments;
  27.     #[ORM\Column(type'boolean'options: ['default' => 0])]
  28.     private bool $active false;
  29.     public function __construct()
  30.     {
  31.         $this->user = new SuluUser();
  32.         $this->payments = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getUser(): UserInterface
  39.     {
  40.         return $this->user;
  41.     }
  42.     public function setUser(UserInterface $user): self
  43.     {
  44.         $this->user $user;
  45.         return $this;
  46.     }
  47.     public function getArticleIdentifier(): string
  48.     {
  49.         return $this->articleIdentifier;
  50.     }
  51.     public function setArticleIdentifier(string $articleIdentifier): self
  52.     {
  53.         $this->articleIdentifier $articleIdentifier;
  54.         return $this;
  55.     }
  56.     public function isActive(): bool
  57.     {
  58.         return $this->active;
  59.     }
  60.     public function setActive(bool $active): self
  61.     {
  62.         $this->active $active;
  63.         return $this;
  64.     }
  65.     public function getPayments(): Collection
  66.     {
  67.         return $this->payments;
  68.     }
  69.     /**
  70.      * @psalm-suppress RedundantConditionGivenDocblockType
  71.      */
  72.     public function addPayment(UserArticlePayment $payment): self
  73.     {
  74.         if (!$this->payments->contains($payment)) {
  75.             $this->payments[] = $payment;
  76.             $payment->setUserArticle($this);
  77.         }
  78.         return $this;
  79.     }
  80. }