<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'crop_edit')]
#[ORM\Entity(repositoryClass: 'App\Entity\Repository\CropEditRepository')]
class CropEdit
{
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\Column(type: 'json', nullable: true)]
private $suggested_edit;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_applied;
#[ORM\Column(type: 'boolean', nullable: true)]
private $created_by_alphabeet;
#[ORM\Column(type: 'integer', nullable: true)]
private $needs_moderator;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_read;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_created;
#[ORM\Column(type: 'string', nullable: true)]
private $feedback;
#[ORM\Column(type: 'boolean', nullable: true)]
private $declined;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Crop', inversedBy: 'cropEdit')]
#[ORM\JoinColumn(name: 'crop_id', referencedColumnName: 'id')]
private $crop;
#[ORM\ManyToOne(targetEntity: 'App\Entity\User', inversedBy: 'cropEdit')]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
private $user;
#[ORM\Column(length: 10, nullable: true)]
private ?string $locale = null;
#[ORM\Column(nullable: true)]
private ?array $approved_by = [];
#[ORM\Column(nullable: true)]
private ?array $declined_by = [];
public function __construct() {
$this->date_created = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getSuggestedEdit(): ?array
{
return $this->suggested_edit;
}
public function setSuggestedEdit(?array $suggested_edit): self
{
$this->suggested_edit = $suggested_edit;
return $this;
}
public function getSuggestedEditField(): ?string
{
if (empty($this->suggested_edit)) {
return null;
}
return $this->suggested_edit['field'] ?? null;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->date_created;
}
public function setDateCreated(?\DateTimeInterface $date_created): self
{
$this->date_created = $date_created;
return $this;
}
public function getCrop(): ?Crop
{
return $this->crop;
}
public function setCrop(?Crop $crop): self
{
$this->crop = $crop;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getDateApplied(): ?\DateTimeInterface
{
return $this->date_applied;
}
public function setDateApplied(?\DateTimeInterface $date_applied): self
{
$this->date_applied = $date_applied;
return $this;
}
public function getCreatedByAlphabeet(): ?bool
{
return $this->created_by_alphabeet;
}
public function setCreatedByAlphabeet(?bool $created_by_alphabeet): self
{
$this->created_by_alphabeet = $created_by_alphabeet;
return $this;
}
public function getNeedsModerator(): ?int
{
return $this->needs_moderator;
}
public function setNeedsModerator(?int $needs_moderator): self
{
$this->needs_moderator = $needs_moderator;
return $this;
}
public function getFeedback(): ?string
{
return $this->feedback;
}
public function setFeedback(?string $feedback): self
{
$this->feedback = $feedback;
return $this;
}
public function getDateRead(): ?\DateTimeInterface
{
return $this->date_read;
}
public function setDateRead(?\DateTimeInterface $date_read): self
{
$this->date_read = $date_read;
return $this;
}
public function getDeclined(): ?bool
{
return $this->declined;
}
public function setDeclined(?bool $declined): self
{
$this->declined = $declined;
return $this;
}
public function getLocale(): ?string
{
return $this->locale;
}
public function setLocale(?string $locale): static
{
$this->locale = $locale;
return $this;
}
public function getApprovedBy(): ?array
{
return $this->approved_by;
}
public function setApprovedBy(?array $approved_by): static
{
$this->approved_by = $approved_by;
return $this;
}
public function addApprovedBy(int $userId): static
{
if (!$this->approved_by) {
$this->approved_by = [];
}
if (!in_array($userId, $this->approved_by)) {
$this->approved_by[] = $userId;
}
return $this;
}
public function getApprovalCount(): int
{
if (empty($this->approved_by)) {
return 0;
}
return count($this->approved_by);
}
public function getDeclinedBy(): ?array
{
return $this->declined_by;
}
public function setDeclinedBy(?array $declined_by): static
{
$this->declined_by = $declined_by;
return $this;
}
public function addDeclinedBy(int $userId): static
{
if (!$this->declined_by) {
$this->declined_by = [];
}
if (!in_array($userId, $this->declined_by)) {
$this->declined_by[] = $userId;
}
return $this;
}
public function getDeclineCount(): int
{
if (empty($this->declined_by)) {
return 0;
}
return count($this->declined_by);
}
}