mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 11:18:25 +00:00 
			
		
		
		
	AccompanyingPeriodWork: add referrers field
This commit is contained in:
		@@ -142,6 +142,15 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
 | 
			
		||||
     */
 | 
			
		||||
    private Collection $persons;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ORM\ManyToMany(targetEntity=User::class)
 | 
			
		||||
     * @ORM\JoinTable(name="chill_person_accompanying_period_work_referrer")
 | 
			
		||||
     * @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
 | 
			
		||||
     * @Serializer\Groups({"accompanying_period_work:edit"})
 | 
			
		||||
     * @Serializer\Groups({"accompanying_period_work:create"})
 | 
			
		||||
     */
 | 
			
		||||
    private Collection $referrers;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks")
 | 
			
		||||
     * @ORM\JoinTable(name="chill_person_accompanying_period_work_result")
 | 
			
		||||
@@ -196,6 +205,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
 | 
			
		||||
        $this->thirdParties = new ArrayCollection();
 | 
			
		||||
        $this->persons = new ArrayCollection();
 | 
			
		||||
        $this->accompanyingPeriodWorkEvaluations = new ArrayCollection();
 | 
			
		||||
        $this->referrers = new ArrayCollection();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self
 | 
			
		||||
@@ -497,4 +507,28 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return Collection|User[]
 | 
			
		||||
     */
 | 
			
		||||
    public function getReferrers(): Collection
 | 
			
		||||
    {
 | 
			
		||||
        return $this->referrers;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addReferrer(User $referrer): self
 | 
			
		||||
    {
 | 
			
		||||
        if (!$this->referrers->contains($referrer)) {
 | 
			
		||||
            $this->referrers[] = $referrer;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function removeReferrer(User $referrer): self
 | 
			
		||||
    {
 | 
			
		||||
        $this->referrers->removeElement($referrer);
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,40 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Chill is a software for social workers
 | 
			
		||||
 *
 | 
			
		||||
 * For the full copyright and license information, please view
 | 
			
		||||
 * the LICENSE file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\Migrations\Person;
 | 
			
		||||
 | 
			
		||||
use Doctrine\DBAL\Schema\Schema;
 | 
			
		||||
use Doctrine\Migrations\AbstractMigration;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Add referrers to AccompanyingPeriodWork
 | 
			
		||||
 */
 | 
			
		||||
final class Version20220310063629 extends AbstractMigration
 | 
			
		||||
{
 | 
			
		||||
    public function getDescription(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'Add referrers to AccompanyingPeriodWork';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function up(Schema $schema): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->addSql('CREATE TABLE chill_person_accompanying_period_work_referrer (accompanyingperiodwork_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(accompanyingperiodwork_id, user_id))');
 | 
			
		||||
        $this->addSql('CREATE INDEX IDX_3619F5EBB99F6060 ON chill_person_accompanying_period_work_referrer (accompanyingperiodwork_id)');
 | 
			
		||||
        $this->addSql('CREATE INDEX IDX_3619F5EBA76ED395 ON chill_person_accompanying_period_work_referrer (user_id)');
 | 
			
		||||
        $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBB99F6060 FOREIGN KEY (accompanyingperiodwork_id) REFERENCES chill_person_accompanying_period_work (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
 | 
			
		||||
        $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function down(Schema $schema): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->addSql('DROP TABLE chill_person_accompanying_period_work_referrer');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user