<?php
/**
* Created by PhpStorm.
* User: apple
* Date: 29/03/19
* Time: 2:43 PM
*/
namespace App\AppBundle\MainBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use JsonSerializable;
/**
* AddOns
*
* @ORM\Entity
* @ORM\Table(name="wp_accessibility_states")
* @ORM\HasLifecycleCallbacks()
*/
class WP_Accessibility_States implements JsonSerializable
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", nullable=false)
* @Assert\NotBlank()
*/
private $name;
/**
* @ORM\Column(type="string", nullable=false)
* @Assert\NotBlank()
*/
private $original_name;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank()
*/
private $state_code;
/**
* @ORM\Column(type="boolean", nullable=false)
* @Assert\NotBlank()
*/
private $active;
/**
* @ORM\Column(type="boolean", nullable=false)
* @Assert\NotBlank()
*/
private $search_city;
/**
* Many features have one product. This is the owning side.
* @ORM\ManyToOne(targetEntity="WP_Accessibility_Country", inversedBy="wp_accessibility_states")
* @ORM\JoinColumn(name="wp_accessibility_country_id", referencedColumnName="id")
*/
private $wp_accessibility_country;
/**
* One product has many features. This is the inverse side.
* @ORM\OneToMany(targetEntity="WP_Accessibility_Cities", mappedBy="wp_accessibility_states")
*/
private $wp_accessibility_cities;
/**
* @ORM\Column(type="integer", nullable=true)
* @Assert\NotBlank()
*/
private $web_state_id;
/**
* @ORM\Column(type="integer", nullable=true)
* @Assert\NotBlank()
*/
private $service_state_id;
/**
* @ORM\Column(type="integer", nullable=true)
* @Assert\NotBlank()
*/
private $cities_count;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getOriginalName()
{
return $this->original_name;
}
/**
* @param mixed $original_name
*/
public function setOriginalName($original_name): void
{
$this->original_name = $original_name;
}
/**
* @return mixed
*/
public function getActive()
{
return $this->active;
}
/**
* @param mixed $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* @return mixed
*/
public function getWpAccessibilityCountry()
{
return $this->wp_accessibility_country;
}
/**
* @param mixed $wp_accessibility_country
*/
public function setWpAccessibilityCountry($wp_accessibility_country)
{
$this->wp_accessibility_country = $wp_accessibility_country;
}
/**
* @return mixed
*/
public function getSearchCity()
{
return $this->search_city;
}
/**
* @param mixed $search_city
*/
public function setSearchCity($search_city)
{
$this->search_city = $search_city;
}
/**
* @return mixed
*/
public function getStateCode()
{
return $this->state_code;
}
/**
* @param mixed $state_code
*/
public function setStateCode($state_code)
{
$this->state_code = $state_code;
}
/**
* @return mixed
*/
public function getWpAccessibilityCities()
{
return $this->wp_accessibility_cities;
}
/**
* @param mixed $wp_accessibility_cities
*/
public function setWpAccessibilityCities($wp_accessibility_cities)
{
$this->wp_accessibility_cities = $wp_accessibility_cities;
}
/**
* @return mixed
*/
public function getWebStateId()
{
return $this->web_state_id;
}
/**
* @param mixed $web_state_id
*/
public function setWebStateId($web_state_id): void
{
$this->web_state_id = $web_state_id;
}
/**
* @return mixed
*/
public function getCitiesCount()
{
return $this->cities_count;
}
/**
* @param mixed $cities_count
*/
public function setCitiesCount($cities_count): void
{
$this->cities_count = $cities_count;
}
/**
* @return mixed
*/
public function getServiceStateId()
{
return $this->service_state_id;
}
/**
* @param mixed $service_state_id
*/
public function setServiceStateId($service_state_id): void
{
$this->service_state_id = $service_state_id;
}
public function jsonSerialize()
{
return array(
'id' => $this->id,
'active' => $this->active,
'name' => $this->name,
'original_name' => $this->original_name,
'cities' => ($this->getWpAccessibilityCities() != NULL && $this->search_city == true) ? $this->getWpAccessibilityCities()->toArray() : NULL,
'state_code' => $this->state_code,
'search_city' => $this->search_city,
'web_state_id' => $this->web_state_id,
'cities_count' => $this->cities_count,
'service_state_id' => $this->service_state_id
);
}
/**
* @var string $created
*
* @ORM\Column(name="created_at", type="string", nullable=false)
*/
protected $createdAt;
/**
* @var string $updated
*
* @ORM\Column(name="updated_at", type="string", nullable=false)
*/
protected $updatedAt;
public function getCreatedAt()
{
return $this->createdAt;
}
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps()
{
$this->setUpdatedAt(round(microtime(true) * 1000));
if ($this->getCreatedAt() === null) {
$this->setCreatedAt(round(microtime(true) * 1000));
}
}
public function __construct() {
$this->wp_accessibility_cities = new ArrayCollection();
$this->setCreatedAt(round(microtime(true) * 1000));
}
}