<?php
declare(strict_types=1);
namespace App\Entity\Profile;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Table(name: 'profile_provided_inventory_items')]
#[UniqueConstraint(name: 'profile_inventory_item_unique', columns: ['profile_id', 'item_id'])]
#[ORM\Entity]
#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'profiles')]
class ProfileProvidedInventoryItem
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[ORM\ManyToOne(targetEntity: Profile::class, inversedBy: 'providedInventoryItems')]
private Profile $profile;
#[ORM\JoinColumn(name: 'item_id', nullable: false)]
#[ORM\ManyToOne(targetEntity: ProfileInventoryItem::class)]
#[Groups(['preview', 'listing'])]
private ProfileInventoryItem $item;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['preview', 'listing'])]
private ?string $comment;
public function __construct(Profile $profile, ProfileInventoryItem $item, ?string $comment = null)
{
$this->profile = $profile;
$this->item = $item;
$this->comment = $comment;
}
public function getId(): int
{
return $this->id;
}
public function getProfile(): Profile
{
return $this->profile;
}
public function getItem(): ProfileInventoryItem
{
return $this->item;
}
public function getComment(): ?string
{
return $this->comment;
}
public function updateComment(?string $comment): void
{
$this->comment = '' === $comment ? null : $comment;
}
}