<?php
namespace App\Entity\Scholar\Training;
use App\Entity\Channel\LockByInterface;
use App\Repository\Scholar\SharedTrainingRepository;
use Doctrine\ORM\Mapping as ORM;
use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[
ORM\Table(name: 'scholar_shared_trainings'),
ORM\Entity(repositoryClass: SharedTrainingRepository::class),
]
#[UniqueEntity(
fields: ['lockBy', 'ownerChannel'],
)]
class SharedTraining extends Training implements LockByInterface
{
#[ORM\ManyToOne(targetEntity: Training::class, fetch: 'EAGER', inversedBy: 'sharedTrainings')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?Training $lockBy = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $lockByStatus = null;
public function getLockBy(): ?Training
{
return $this->lockBy;
}
public function setLockBy(?Training $lockBy): static
{
$this->lockBy = $lockBy;
return $this;
}
public function getLockByStatus(): ?bool
{
return $this->lockByStatus;
}
public function setLockByStatus(?bool $lockByStatus): static
{
$this->lockByStatus = $lockByStatus;
return $this;
}
public function getLockByOwnerChannel(): ?ChannelInterface
{
return $this->getLockBy()?->getOwnerChannel();
}
}