relation between task and accompanyingcourse created

This commit is contained in:
Julie Lenaerts 2021-09-09 17:43:35 +02:00
parent 9851efa804
commit 8318458805
2 changed files with 58 additions and 1 deletions

View File

@ -10,6 +10,7 @@ use Chill\MainBundle\Entity\HasScopeInterface;
use Chill\MainBundle\Entity\HasCenterInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
/**
* AbstractTask
@ -67,9 +68,16 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person"
* )
* @Assert\NotNull()
*/
private $person;
/**
* @var AccompanyingPeriod
* @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod")
*/
private $course;
/**
*
@ -202,6 +210,11 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
return $this->person;
}
public function getCourse(): ?AccompanyingPeriod
{
return $this->course;
}
public function getCircle(): ?Scope
{
return $this->circle;
@ -219,6 +232,12 @@ abstract class AbstractTask implements HasScopeInterface, HasCenterInterface
return $this;
}
public function setCourse(AccompanyingPeriod $course)
{
$this->course = $course;
return $this;
}
public function setCircle(Scope $circle)
{
$this->circle = $circle;

View File

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Chill\TaskBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210909153533 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_task.recurring_task ADD course_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_task.recurring_task ADD CONSTRAINT FK_9F663B90591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_9F663B90591CC992 ON chill_task.recurring_task (course_id)');
$this->addSql('ALTER TABLE chill_task.single_task ADD course_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D8591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_194CB3D8591CC992 ON chill_task.single_task (course_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_task.recurring_task DROP CONSTRAINT FK_9F663B90591CC992');
$this->addSql('ALTER TABLE chill_task.recurring_task DROP course_id');
$this->addSql('ALTER TABLE chill_task.single_task DROP CONSTRAINT FK_194CB3D8591CC992');
$this->addSql('ALTER TABLE chill_task.single_task DROP course_id');
}
}