src/Entity/Scholar/Training/SharedTraining.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Scholar\Training;
  3. use App\Entity\Channel\LockByInterface;
  4. use App\Entity\Scholar\SharedScholarTrait;
  5. use App\Repository\Scholar\SharedTrainingRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. #[
  10. ORM\Table(name: 'scholar_shared_trainings'),
  11. ORM\Entity(repositoryClass: SharedTrainingRepository::class),
  12. ]
  13. #[UniqueEntity(
  14. fields: ['lockBy', 'ownerChannel'],
  15. )]
  16. class SharedTraining extends Training implements LockByInterface
  17. {
  18. use SharedScholarTrait;
  19. #[ORM\ManyToOne(targetEntity: Training::class, fetch: 'EAGER', inversedBy: 'sharedTrainings')]
  20. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  21. private ?Training $lockBy = null;
  22. #[ORM\Column(type: 'integer', nullable: true)]
  23. private ?int $lockByStatus = null;
  24. public function getLockBy(): ?Training
  25. {
  26. return $this->lockBy;
  27. }
  28. public function setLockBy(?Training $lockBy): static
  29. {
  30. $this->lockBy = $lockBy;
  31. return $this;
  32. }
  33. public function getLockByStatus(): ?bool
  34. {
  35. return $this->lockByStatus;
  36. }
  37. public function setLockByStatus(?bool $lockByStatus): static
  38. {
  39. $this->lockByStatus = $lockByStatus;
  40. return $this;
  41. }
  42. public function getLockByOwnerChannel(): ?ChannelInterface
  43. {
  44. return $this->getLockBy()?->getOwnerChannel();
  45. }
  46. }