src/Entity/Profile/ProfileProvidedInventoryItem.php line 15

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Profile;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\ORM\Mapping\UniqueConstraint;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. #[ORM\Table(name: 'profile_provided_inventory_items')]
  8. #[UniqueConstraint(name: 'profile_inventory_item_unique', columns: ['profile_id', 'item_id'])]
  9. #[ORM\Entity]
  10. #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'profiles')]
  11. class ProfileProvidedInventoryItem
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue(strategy: 'AUTO')]
  15.     #[ORM\Column(type: 'integer')]
  16.     private int $id;
  17.     #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  18.     #[ORM\ManyToOne(targetEntity: Profile::class, inversedBy: 'providedInventoryItems')]
  19.     private Profile $profile;
  20.     #[ORM\JoinColumn(name: 'item_id', nullable: false)]
  21.     #[ORM\ManyToOne(targetEntity: ProfileInventoryItem::class)]
  22.     #[Groups(['preview', 'listing'])]
  23.     private ProfileInventoryItem $item;
  24.     #[ORM\Column(type: 'string', length: 255, nullable: true)]
  25.     #[Groups(['preview', 'listing'])]
  26.     private ?string $comment;
  27.     public function __construct(Profile $profile, ProfileInventoryItem $item, ?string $comment = null)
  28.     {
  29.         $this->profile = $profile;
  30.         $this->item = $item;
  31.         $this->comment = $comment;
  32.     }
  33.     public function getId(): int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getProfile(): Profile
  38.     {
  39.         return $this->profile;
  40.     }
  41.     public function getItem(): ProfileInventoryItem
  42.     {
  43.         return $this->item;
  44.     }
  45.     public function getComment(): ?string
  46.     {
  47.         return $this->comment;
  48.     }
  49.     public function updateComment(?string $comment): void
  50.     {
  51.         $this->comment = '' === $comment ? null : $comment;
  52.     }
  53. }