<?php
namespace App\AppBundle\AdminBundle\Entity;
use App\AppBundle\MainBundle\Entity\User;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use Symfony\Component\Validator\Constraints as Assert;
/**
* AddOns
*
* @ORM\Entity(repositoryClass="App\AppBundle\AdminBundle\Repository\NotificationsSMSToUsersRepository")
* @ORM\Table(name="notifications_sms_to_users")
* @ORM\HasLifecycleCallbacks()
*/
class NotificationsSMSToUsers implements JsonSerializable
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var ArrayCollection
* @ORM\ManyToMany(targetEntity="App\AppBundle\MainBundle\Entity\User")
* @ORM\JoinTable(name="notifications_sms_to_users_users",
* joinColumns={@ORM\JoinColumn(name="notifications_sms_to_users_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
* )
*/
private $users;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $other_phone_numbers;
/**
* @ORM\Column(type="string", nullable=false, length=5000)
*/
private $description;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
*/
private $active = true;
/**
* @ORM\Column(type="boolean", nullable=false)
*/
private $is_notified = false;
/**
* @var DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $schedule_at;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 0})
*/
private $send_to_all = false;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return ArrayCollection
*/
public function getUsers()
{
return $this->users;
}
/**
* @param ArrayCollection $users
*/
public function setUsers($users)
{
$this->users = $users;
}
/**
* @param User $user
*
* @return NotificationsSMSToUsers
*/
public function addUser(User $user) {
if (!$this->users->contains($user)) {
$this->users->add($user);
}
return $this;
}
/**
* @param User $user
*/
public function removeUser(User $user) {
$this->users->removeElement($user);
}
/**
* @return mixed
*/
public function getDescription()
{
return $this->description;
}
/**
* @param mixed $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return mixed
*/
public function getActive()
{
return $this->active;
}
/**
* @param mixed $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* @return bool
*/
public function isIsNotified()
{
return $this->is_notified;
}
/**
* @param bool $is_notified
*/
public function setIsNotified($is_notified)
{
$this->is_notified = $is_notified;
}
/**
* @return mixed
*/
public function getScheduleAt()
{
return $this->schedule_at;
}
/**
* @param mixed $schedule_at
*/
public function setScheduleAt($schedule_at)
{
$this->schedule_at = $schedule_at;
}
/**
* @return mixed
*/
public function getOtherPhoneNumbers()
{
return $this->other_phone_numbers;
}
/**
* @param mixed $other_phone_numbers
*/
public function setOtherPhoneNumbers($other_phone_numbers)
{
$this->other_phone_numbers = $other_phone_numbers;
}
/**
* @return bool
*/
public function isSendToAll()
{
return $this->send_to_all;
}
/**
* @param bool $send_to_all
*/
public function setSendToAll(bool $send_to_all)
{
$this->send_to_all = $send_to_all;
}
public function jsonSerialize()
{
return array(
'id' => $this->id,
'other_phone_numbers' => $this->other_phone_numbers,
'description' => $this->description,
'active' => $this->active,
'send_to_all' => $this->send_to_all,
'is_notified' => $this->is_notified,
'schedule_at' => $this->schedule_at != NULL ? $this->schedule_at->format('Y-m-d H:i:s') : '',
'created' => $this->createdAt->format('Y-m-d H:i:s'),
'updated' => $this->updatedAt->format('Y-m-d H:i:s'),
);
}
/**
* @var DateTime $created
*
* @ORM\Column(type="datetime", nullable=false)
*/
protected $createdAt;
/**
* @var DateTime $updated
*
* @ORM\Column(type="datetime", nullable=false)
*/
protected $updatedAt;
/**
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue() {
$this->updatedAt = new DateTime();
}
public function __construct() {
$this->users = new ArrayCollection();
}
}