<?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\NotificationsPushToUsersRepository")
* @ORM\Table(name="notifications_push_to_users")
* @ORM\HasLifecycleCallbacks()
*/
class NotificationsPushToUsers 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_push_to_users_users",
* joinColumns={@ORM\JoinColumn(name="notifications_push_to_users_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
* )
*/
private $users;
/**
* @ORM\Column(type="string", nullable=false)
*/
private $title;
/**
* @ORM\Column(type="string", nullable=false, length=5000)
*/
private $description;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $image;
/**
* @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 NotificationsPushToUsers
*/
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 getTitle()
{
return $this->title;
}
/**
* @param mixed $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return mixed
*/
public function getDescription()
{
return $this->description;
}
/**
* @param mixed $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return mixed
*/
public function getImage()
{
return $this->image;
}
/**
* @param mixed $image
*/
public function setImage($image)
{
$this->image = $image;
}
/**
* @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 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,
'title' => $this->title,
'description' => $this->description,
'image' => $this->image,
'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();
}
}