<?php
namespace App\Entity;
use App\Repository\ReminderRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ReminderRepository::class)]
class Reminder
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: Crop::class)]
private $crop;
#[ORM\ManyToOne(targetEntity: Cropaction::class)]
private $cropaction;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'reminders')]
#[ORM\JoinColumn(nullable: false)]
private $user;
#[ORM\Column(type: 'datetime')]
private $reminderAt;
#[ORM\Column(type: 'json', nullable: true)]
private $repeatpattern = [];
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $title;
#[ORM\Column(type: 'datetime')]
private $createdAt;
#[ORM\Column(type: 'datetime', nullable: true)]
private $updatedAt;
public function __construct() {
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getCrop(): ?Crop
{
return $this->crop;
}
public function setCrop(?Crop $crop): self
{
$this->crop = $crop;
return $this;
}
public function getCropaction(): ?Cropaction
{
return $this->cropaction;
}
public function setCropaction(?Cropaction $cropaction): self
{
$this->cropaction = $cropaction;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getReminderAt(): ?\DateTimeInterface
{
return $this->reminderAt;
}
public function setReminderAt(\DateTimeInterface $reminderAt): self
{
$this->reminderAt = $reminderAt;
return $this;
}
public function getRepeatpattern(): ?array
{
return $this->repeatpattern;
}
public function setRepeatpattern(?array $repeatpattern): self
{
$this->repeatpattern = $repeatpattern;
return $this;
}
public function getTitle(): ?string
{
if( !empty($this->cropaction) ) {
return $this->getCropaction()->getTitle();
}
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
}