src/Entity/NotificationCustomerSetting.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Notification\BaseNotification;
  4. use App\Repository\NotificationCustomerSettingRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=NotificationCustomerSettingRepository::class)
  8.  * @ORM\HasLifecycleCallbacks()
  9.  */
  10. class NotificationCustomerSetting extends BaseEntity
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="notificationCustomerSettings")
  20.      * @ORM\JoinColumn(nullable=false)
  21.      */
  22.     private $customer;
  23.     /**
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $notification_type;
  27.     /**
  28.      * @ORM\Column(type="integer")
  29.      */
  30.     private $email;
  31.     /**
  32.      * @ORM\Column(type="integer")
  33.      */
  34.     private $sms;
  35.     /**
  36.      * @ORM\Column(type="integer")
  37.      */
  38.     private $profile;
  39.     /**
  40.      * @ORM\Column(type="datetime", nullable=true)
  41.      */
  42.     private $created_at;
  43.     /**
  44.      * @ORM\Column(type="datetime", nullable=true)
  45.      */
  46.     private $updated_at;
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getCustomer(): ?Customer
  52.     {
  53.         return $this->customer;
  54.     }
  55.     public function setCustomer(?Customer $customer): self
  56.     {
  57.         $this->customer $customer;
  58.         return $this;
  59.     }
  60.     public function getNotificationType(): ?int
  61.     {
  62.         return $this->notification_type;
  63.     }
  64.     public function setNotificationType(int $notification_type): self
  65.     {
  66.         $this->notification_type $notification_type;
  67.         return $this;
  68.     }
  69.     public function getEmail(): ?bool
  70.     {
  71.         return $this->email;
  72.     }
  73.     public function setEmail(bool $email): self
  74.     {
  75.         $this->email $email;
  76.         return $this;
  77.     }
  78.     public function getSms(): ?bool
  79.     {
  80.         return $this->sms;
  81.     }
  82.     public function setSms(bool $sms): self
  83.     {
  84.         $this->sms $sms;
  85.         return $this;
  86.     }
  87.     public function getProfile(): ?bool
  88.     {
  89.         return $this->profile;
  90.     }
  91.     public function setProfile(bool $profile): self
  92.     {
  93.         $this->profile $profile;
  94.         return $this;
  95.     }
  96.     public function getCreatedAt(): ?\DateTimeInterface
  97.     {
  98.         return $this->created_at;
  99.     }
  100.     public function setCreatedAt(?\DateTimeInterface $created_at): self
  101.     {
  102.         $this->created_at $created_at;
  103.         return $this;
  104.     }
  105.     public function getUpdatedAt(): ?\DateTimeInterface
  106.     {
  107.         return $this->updated_at;
  108.     }
  109.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  110.     {
  111.         $this->updated_at $updated_at;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @ORM\PrePersist
  116.      * @ORM\PreUpdate
  117.      */
  118.     public function updatedTimestamps(): void
  119.     {
  120.         $now = new \DateTime('now');
  121.         $this->setUpdatedAt($now);
  122.         if (null === $this->getCreatedAt()) {
  123.             $this->setCreatedAt($now);
  124.         }
  125.     }
  126.     public function toArray()
  127.     {
  128.         return [
  129.             'id'                => $this->getId(),
  130.             'notification_type' => $this->getNotificationType(),
  131.             'email'             => [
  132.                 'active' => $this->getEmail(),
  133.             ],
  134.             'sms'             => [
  135.                 'active' => $this->getSms(),
  136.             ],
  137.             'system'             => [
  138.                 'active' => $this->getProfile(),
  139.             ],
  140.         ];
  141.     }
  142. }