<?php
namespace App\Entity;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use App\Repository\MobileParentAppAccountRepository;
/**
* @ORM\Entity(repositoryClass=MobileParentAppAccountRepository::class)
*/
class MobileParentAppAccount
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=128)
*/
private $last_name;
/**
* @ORM\Column(type="string", length=128)
*/
private $first_name;
/**
* @ORM\Column(type="string", length=128)
*/
private $phone_number;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $username;
/**
* @ORM\Column(type="string", length=255)
*/
private $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $device_token;
/**
* @ORM\ManyToOne(targetEntity=Establishment::class, inversedBy="mobileParentAppAccounts")
* @ORM\JoinColumn(nullable=false)
*/
private $establishment;
/**
* @ORM\Column(type="boolean")
*/
private $is_enabled;
/**
* @ORM\Column(type="boolean")
*/
private $is_password_changed;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $last_auth_time;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $token;
/**
* @ORM\Column(type="date_immutable")
*/
private $create_at;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $created_at;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $updated_at;
/**
* @ORM\Column(type="integer")
*/
private $created_by;
/**
* @ORM\Column(type="integer")
*/
private $updated_by;
/**
* @ORM\ManyToMany(targetEntity=RegistrationStudent::class, inversedBy="mobileParentAppAccounts")
*/
private $registrationStudents;
/**
* @ORM\OneToMany(targetEntity=MobileParentAppAccountActivity::class, mappedBy="mobileParentAppAccount")
*/
private $mobileParentAppAccountActivities;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $device;
public function __construct()
{
$this->is_enabled = true;
$this->is_password_changed = false;
$this->registrationStudents = new ArrayCollection();
$this->create_at = new DateTimeImmutable();
$this->mobileParentAppAccountActivities = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function getEstablishment(): ?Establishment
{
return $this->establishment;
}
public function setEstablishment(?Establishment $establishment): self
{
$this->establishment = $establishment;
return $this;
}
public function getIsEnabled(): ?bool
{
return $this->is_enabled;
}
public function setIsEnabled(bool $is_enabled): self
{
$this->is_enabled = $is_enabled;
return $this;
}
public function getIsPasswordChanged(): ?bool
{
return $this->is_password_changed;
}
public function setIsPasswordChanged(bool $is_password_changed): self
{
$this->is_password_changed = $is_password_changed;
return $this;
}
public function getLastAuthTime(): ?int
{
return $this->last_auth_time;
}
public function setLastAuthTime(?int $last_auth_time): self
{
$this->last_auth_time = $last_auth_time;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
/**
* @return Collection|RegistrationStudent[]
*/
public function getRegistrationStudents(): Collection
{
return $this->registrationStudents;
}
public function addRegistrationStudent(RegistrationStudent $registrationStudent): self
{
if (!$this->registrationStudents->contains($registrationStudent)) {
$this->registrationStudents[] = $registrationStudent;
}
return $this;
}
public function removeRegistrationStudent(RegistrationStudent $registrationStudent): self
{
$this->registrationStudents->removeElement($registrationStudent);
return $this;
}
public function getLastName(): ?string
{
return $this->last_name;
}
public function setLastName(string $last_name): self
{
$this->last_name = $last_name;
return $this;
}
public function getFirstName(): ?string
{
return $this->first_name;
}
public function setFirstName(string $first_name): self
{
$this->first_name = $first_name;
return $this;
}
public function getPhoneNumber(): ?string
{
return $this->phone_number;
}
public function setPhoneNumber(string $phone_number): self
{
$this->phone_number = $phone_number;
return $this;
}
public function getCreateAt(): ?\DateTimeImmutable
{
return $this->create_at;
}
public function setCreateAt(\DateTimeImmutable $create_at): self
{
$this->create_at = $create_at;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeImmutable $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getCreatedBy(): ?int
{
return $this->created_by;
}
public function setCreatedBy(int $created_by): self
{
$this->created_by = $created_by;
return $this;
}
public function getUpdatedBy(): ?int
{
return $this->updated_by;
}
public function setUpdatedBy(int $updated_by): self
{
$this->updated_by = $updated_by;
return $this;
}
public function isTokenValid()
{
return ($this->getLastAuthTime() + 604800) > time();
}
/**
* @return Collection|MobileParentAppAccountActivity[]
*/
public function getMobileParentAppAccountActivities(): Collection
{
return $this->mobileParentAppAccountActivities;
}
public function addMobileParentAppAccountActivity(MobileParentAppAccountActivity $mobileParentAppAccountActivity): self
{
if (!$this->mobileParentAppAccountActivities->contains($mobileParentAppAccountActivity)) {
$this->mobileParentAppAccountActivities[] = $mobileParentAppAccountActivity;
$mobileParentAppAccountActivity->setMobileParentAppAccount($this);
}
return $this;
}
public function removeMobileParentAppAccountActivity(MobileParentAppAccountActivity $mobileParentAppAccountActivity): self
{
if ($this->mobileParentAppAccountActivities->removeElement($mobileParentAppAccountActivity)) {
// set the owning side to null (unless already changed)
if ($mobileParentAppAccountActivity->getMobileParentAppAccount() === $this) {
$mobileParentAppAccountActivity->setMobileParentAppAccount(null);
}
}
return $this;
}
public function getDevice(): ?string
{
return $this->device;
}
public function setDevice(?string $device): self
{
$this->device = $device;
return $this;
}
public function getDeviceToken(): ?string
{
return $this->device_token;
}
public function setDeviceToken(?string $device_token): self
{
$this->device_token = $device_token;
return $this;
}
}