<?php
namespace App\Entity;
use App\Repository\RecordRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;
#[ORM\Entity(repositoryClass: RecordRepository::class)]
class Record
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
private ?\DateTimeImmutable $recordTime = null;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
private ?\DateTimeImmutable $syncTime = null;
#[ORM\Column]
private ?float $price = null;
#[ORM\ManyToOne(targetEntity: Product::class, inversedBy: 'records', cascade: ['persist'])]
private ?Product $product = null;
#[ORM\ManyToOne(targetEntity: Shop::class, cascade: ['persist'])]
#[Ignore]
private ?Shop $shop = null;
#[ORM\Column(length: 255)]
private ?string $contentHash = '';
#[ORM\OneToMany(mappedBy: 'record', targetEntity: Photo::class, cascade: ['persist', 'remove'])]
private Collection $photos;
#[ORM\ManyToOne(targetEntity: User::class)]
private ?User $user = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $photoConcat = null;
public function __construct()
{
$this->photos = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): static
{
$this->price = $price;
return $this;
}
public function getShop(): ?Shop
{
return $this->shop;
}
public function setShop(?Shop $shop): static
{
$this->shop = $shop;
return $this;
}
public function getRecordTime(): ?\DateTimeImmutable
{
return $this->recordTime;
}
public function setRecordTime(\DateTimeImmutable $recordTime): static
{
$this->recordTime = $recordTime;
return $this;
}
public function getSyncTime(): ?\DateTimeImmutable
{
return $this->syncTime;
}
public function setSyncTime(\DateTimeImmutable $syncTime): static
{
$this->syncTime = $syncTime;
return $this;
}
public function getContentHash(): ?string
{
return $this->contentHash;
}
public function setContentHash(string $contentHash): static
{
$this->contentHash = $contentHash;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
/**
* @return Collection<int, Photo>
*/
public function getPhotos(): Collection
{
return $this->photos;
}
public function addPhoto(Photo $photo): static
{
if (!$this->photos->contains($photo)) {
$this->photos->add($photo);
$photo->setRecord($this);
}
return $this;
}
public function removePhoto(Photo $photo): static
{
if ($this->photos->removeElement($photo)) {
// set the owning side to null (unless already changed)
if ($photo->getRecord() === $this) {
$photo->setRecord(null);
}
}
return $this;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(?Product $product): static
{
$this->product = $product;
return $this;
}
public function getPhotoConcat(): ?string
{
return $this->photoConcat;
}
public function setPhotoConcat(?string $photoConcat): static
{
$this->photoConcat = $photoConcat;
return $this;
}
}