src/Entity/MonthlyTestPlan.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\ORM\Mapping\UniqueConstraint;
  6. use EightMarq\CoreComponent\Entity\BaseEntity;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Table(name="monthly_test_plans", uniqueConstraints={
  12.  *     @UniqueConstraint(columns={"date", "deleted_at"})
  13.  * })
  14.  *
  15.  * @UniqueEntity(fields={"date"}, errorPath="date", message="error.monthly_test_plan.duplicaiton")
  16.  *
  17.  * @ORM\Entity()
  18.  *
  19.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true, hardDelete=false)
  20.  */
  21. class MonthlyTestPlan extends BaseEntity
  22. {
  23.     /**
  24.      * @var DateTime | null
  25.      *
  26.      * @ORM\Column(type="datetime")
  27.      *
  28.      *
  29.      * @Assert\NotBlank()
  30.      */
  31.     protected $date;
  32.     /**
  33.      * @var int | null
  34.      *
  35.      * @ORM\Column(type="integer")
  36.      *
  37.      *
  38.      * @Assert\NotBlank()
  39.      * @Assert\GreaterThanOrEqual(0)
  40.      */
  41.     protected $value;
  42.     public function __toString()
  43.     {
  44.         return $this->getDate() ? $this->getDate()->format('Y-m') : '';
  45.     }
  46.     /**
  47.      * @return DateTime|null
  48.      */
  49.     public function getDate(): ?DateTime
  50.     {
  51.         return $this->date;
  52.     }
  53.     /**
  54.      * @param DateTime|null $date
  55.      */
  56.     public function setDate(?DateTime $date): void
  57.     {
  58.         $this->date $date;
  59.     }
  60.     /**
  61.      * @return int|null
  62.      */
  63.     public function getValue(): ?int
  64.     {
  65.         return $this->value;
  66.     }
  67.     /**
  68.      * @param int|null $value
  69.      */
  70.     public function setValue(?int $value): void
  71.     {
  72.         $this->value $value;
  73.     }
  74. }