Added ability to view part relations on a part info page

This commit is contained in:
Jan Böhmer 2023-11-15 00:44:45 +01:00
parent cc2332a83a
commit 7f612bc371
7 changed files with 143 additions and 0 deletions

View file

@ -23,7 +23,9 @@ declare(strict_types=1);
namespace App\Entity\Parts\PartTraits;
use App\Entity\Parts\Part;
use App\Entity\Parts\PartAssociation;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints\Valid;
use Doctrine\ORM\Mapping as ORM;
@ -89,4 +91,18 @@ trait AssociationTrait
{
return $this->associated_parts_as_other;
}
/**
* Returns all associations where this part is the owned or other part.
* @return Collection<PartAssociation>
*/
public function getAssociatedPartsAll(): Collection
{
return new ArrayCollection(
array_merge(
$this->associated_parts_as_owner->toArray(),
$this->associated_parts_as_other->toArray()
)
);
}
}