Added support entity
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Entity\Gateway;
|
||||
use App\Entity\Accounting\Accounting;
|
||||
use App\Entity\Accounting\Transaction;
|
||||
use App\Entity\Money;
|
||||
use App\Entity\Project\Support;
|
||||
use App\Gateway\ChargeType;
|
||||
use App\Mapping\Provider\EntityMapProvider;
|
||||
use App\Repository\Gateway\ChargeRepository;
|
||||
@@ -73,6 +74,9 @@ class Charge
|
||||
#[ORM\ManyToMany(targetEntity: Transaction::class, cascade: ['persist'])]
|
||||
private Collection $transactions;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'charges')]
|
||||
private ?Support $support = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->transactions = new ArrayCollection();
|
||||
@@ -178,4 +182,16 @@ class Charge
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSupport(): ?Support
|
||||
{
|
||||
return $this->support;
|
||||
}
|
||||
|
||||
public function setSupport(?Support $support): static
|
||||
{
|
||||
$this->support = $support;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,12 +116,19 @@ class Project implements UserOwnedInterface, AccountingOwnerInterface, Localized
|
||||
#[ORM\OneToMany(targetEntity: Update::class, mappedBy: 'project', cascade: ['persist'])]
|
||||
private Collection $updates;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Support>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Support::class, mappedBy: 'project')]
|
||||
private Collection $supports;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->accounting = Accounting::of($this);
|
||||
$this->rewards = new ArrayCollection();
|
||||
$this->budgetItems = new ArrayCollection();
|
||||
$this->updates = new ArrayCollection();
|
||||
$this->supports = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -345,4 +352,34 @@ class Project implements UserOwnedInterface, AccountingOwnerInterface, Localized
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Support>
|
||||
*/
|
||||
public function getSupports(): Collection
|
||||
{
|
||||
return $this->supports;
|
||||
}
|
||||
|
||||
public function addSupport(Support $support): static
|
||||
{
|
||||
if (!$this->supports->contains($support)) {
|
||||
$this->supports->add($support);
|
||||
$support->setProject($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSupport(Support $support): static
|
||||
{
|
||||
if ($this->supports->removeElement($support)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($support->getProject() === $this) {
|
||||
$support->setProject(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Project;
|
||||
|
||||
use App\Entity\Gateway\Charge;
|
||||
use App\Entity\User\User;
|
||||
use App\Repository\Project\SupportRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SupportRepository::class)]
|
||||
class Support
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'supports')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $owner = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'supports')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Project $project = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Charge>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Charge::class, mappedBy: 'support')]
|
||||
private Collection $charges;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $message = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?bool $anonymours = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->charges = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getOwner(): ?User
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function setOwner(?User $owner): static
|
||||
{
|
||||
$this->owner = $owner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProject(): ?Project
|
||||
{
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
public function setProject(?Project $project): static
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Charge>
|
||||
*/
|
||||
public function getCharges(): Collection
|
||||
{
|
||||
return $this->charges;
|
||||
}
|
||||
|
||||
public function addCharge(Charge $charge): static
|
||||
{
|
||||
if (!$this->charges->contains($charge)) {
|
||||
$this->charges->add($charge);
|
||||
$charge->setSupport($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeCharge(Charge $charge): static
|
||||
{
|
||||
if ($this->charges->removeElement($charge)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($charge->getSupport() === $this) {
|
||||
$charge->setSupport(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function setMessage(?string $message): static
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAnonymours(): ?bool
|
||||
{
|
||||
return $this->anonymours;
|
||||
}
|
||||
|
||||
public function setAnonymours(bool $anonymours): static
|
||||
{
|
||||
$this->anonymours = $anonymours;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Entity\User;
|
||||
use App\Entity\Accounting\Accounting;
|
||||
use App\Entity\Interface\AccountingOwnerInterface;
|
||||
use App\Entity\Project\Project;
|
||||
use App\Entity\Project\Support;
|
||||
use App\Entity\Trait\MigratedEntity;
|
||||
use App\Entity\Trait\TimestampedCreationEntity;
|
||||
use App\Entity\Trait\TimestampedUpdationEntity;
|
||||
@@ -111,6 +112,12 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, Account
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $avatar = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Support>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Support::class, mappedBy: 'owner')]
|
||||
private Collection $supports;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->accounting = Accounting::of($this);
|
||||
@@ -121,6 +128,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, Account
|
||||
|
||||
$this->emailConfirmed = false;
|
||||
$this->active = false;
|
||||
$this->supports = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -369,4 +377,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, Account
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Support>
|
||||
*/
|
||||
public function getSupports(): Collection
|
||||
{
|
||||
return $this->supports;
|
||||
}
|
||||
|
||||
public function addSupport(Support $support): static
|
||||
{
|
||||
if (!$this->supports->contains($support)) {
|
||||
$this->supports->add($support);
|
||||
$support->setOwner($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSupport(Support $support): static
|
||||
{
|
||||
if ($this->supports->removeElement($support)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($support->getOwner() === $this) {
|
||||
$support->setOwner(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository\Project;
|
||||
|
||||
use App\Entity\Project\Support;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Support>
|
||||
*/
|
||||
class SupportRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Support::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Support[] Returns an array of Support objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('s.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Support
|
||||
// {
|
||||
// return $this->createQueryBuilder('s')
|
||||
// ->andWhere('s.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user