<?php
namespace App\Entity;
use App\Translation\AutoTranslatableTrait;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
#[ORM\Table(name: 'cropaction')]
#[ORM\Entity(repositoryClass: 'App\Entity\Repository\CropactionRepository')]
class Cropaction implements TranslatableInterface
{
use AutoTranslatableTrait;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\Column(type: 'integer', nullable: true)]
private $days_start;
#[ORM\Column(type: 'integer', nullable: true)]
private $days_end;
#[ORM\Column(type: 'integer', nullable: true)]
private $repeat_days;
#[ORM\Column(type: 'string', nullable: true)]
private $title;
#[ORM\Column(type: 'string', nullable: true)]
private $type;
#[ORM\Column(type: 'text', nullable: true)]
private $text;
#[ORM\Column(type: 'text', nullable: true)]
private $notification_text;
#[ORM\Column(type: 'json', nullable: true)]
private $additional_data;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_created;
#[ORM\Column(type: 'integer', nullable: true)]
private $priority;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Crop', inversedBy: 'cropaction')]
#[ORM\JoinColumn(name: 'crop_id', referencedColumnName: 'id', nullable: false)]
private $crop;
#[ORM\ManyToOne(targetEntity: 'App\Entity\User', inversedBy: 'cropaction')]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
private $user;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_updated;
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
if ($this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->title;
}
$translated = $this->translate()->getTitle();
return !empty($translated) ? $translated : $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getText(): ?string
{
if ($this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->text;
}
$translated = $this->translate()->getText();
return !empty($translated) ? $translated : $this->text;
}
public function setText(?string $text): self
{
$this->text = $text;
return $this;
}
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 getRepeatDays(): ?int
{
return $this->repeat_days;
}
public function setRepeatDays(?int $repeat_days): self
{
$this->repeat_days = $repeat_days;
return $this;
}
public function getAdditionalData()
{
if ($this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->additional_data;
}
$translated = $this->translate()->getAdditionalData();
return !empty($translated) ? $translated : $this->additional_data;
}
public function setAdditionalData($additional_data): self
{
$this->additional_data = $additional_data;
return $this;
}
public function getNotificationText(): ?string
{
if ($this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->notification_text;
}
$translated = $this->translate()->getNotificationText();
return !empty($translated) ? $translated : $this->notification_text;
}
public function setNotificationText(?string $notification_text): self
{
$this->notification_text = $notification_text;
return $this;
}
public function getDaysStart(): ?int
{
return $this->days_start;
}
public function setDaysStart(?int $days_start): self
{
$this->days_start = $days_start;
return $this;
}
public function getDaysEnd(): ?int
{
return $this->days_end;
}
public function setDaysEnd(?int $days_end): self
{
$this->days_end = $days_end;
return $this;
}
public function getPriority(): ?int
{
return $this->priority;
}
public function setPriority(?int $priority): self
{
$this->priority = $priority;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getDateUpdated(): ?\DateTimeInterface
{
return $this->date_updated;
}
public function setDateUpdated(?\DateTimeInterface $date_updated): self
{
$this->date_updated = $date_updated;
return $this;
}
public function moveDaysBy(int $days): self
{
$this->days_start += $days;
if ($this->days_end !== null) {
$this->days_end += $days;
}
return $this;
}
public function scaleDaysBy(float $scale): self
{
$this->days_start = round($this->days_start * $scale);
if ($this->days_end !== null) {
$this->days_end = round($this->days_end * $scale);
}
return $this;
}
}