mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 01:49:05 +02:00
Use new UniqueObjectCollection constraint to ensure that BOM entries does not contain duplicate items
This commit is contained in:
parent
7b87b00b44
commit
e72b120c12
7 changed files with 223 additions and 7 deletions
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
namespace App\Entity\ProjectSystem;
|
||||
|
||||
use App\Repository\Parts\DeviceRepository;
|
||||
use App\Validator\Constraints\UniqueObjectCollection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use App\Entity\Attachments\ProjectAttachment;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
|
@ -56,6 +57,8 @@ class Project extends AbstractStructuralDBElement
|
|||
#[Assert\Valid]
|
||||
#[Groups(['extended', 'full'])]
|
||||
#[ORM\OneToMany(targetEntity: ProjectBOMEntry::class, mappedBy: 'project', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[UniqueObjectCollection(fields: ['part'], message: 'project.bom_entry.part_already_in_bom')]
|
||||
#[UniqueObjectCollection(fields: ['name'], message: 'project.bom_entry.name_already_in_bom')]
|
||||
protected Collection $bom_entries;
|
||||
|
||||
#[ORM\Column(type: Types::INTEGER)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue