Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Fcm\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\ORM\Events;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping\ManyToOne;
- use Doctrine\ORM\Mapping\OneToMany;
- /**
- * @ORM\Table(name="client")
- * @ORM\Entity(repositoryClass="Fcm\Entity\Repository\ClientRepository")
- * @ORM\HasLifecycleCallbacks
- * @property integer $id
- * @property string $name
- * @property string $website
- * @property string $email
- * @property string $contact
- * @property string $phone
- * @property string $comment
- * @property date $created
- */
- class Client
- {
- /**
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- * @ORM\Column(type="integer")
- */
- protected $id;
- /** @ORM\Column(type="string", length=120, nullable=false, unique=false)
- *
- */
- protected $name;
- /** @ORM\Column(type="string", length=120, nullable=true, unique=false) */
- protected $website;
- /** @ORM\Column(type="string", length=120, nullable=true, unique=true) */
- protected $email;
- /** @ORM\Column(type="string", length=120, nullable=true, unique=false) */
- protected $contact;
- /** @ORM\Column(type="string", length=120, nullable=true, unique=false) */
- protected $phone;
- /** @ORM\Column(type="string",length=255, nullable=true, unique=false) */
- protected $comment;
- /** @ORM\OneToMany(targetEntity="Campaign", mappedBy="client", cascade={"remove"}) */
- protected $campaigns;
- /** @ORM\OneToMany(targetEntity="User", mappedBy="client", cascade={"remove"}) */
- protected $users;
- /**
- * @var date $created
- *
- * @ORM\Column(name="created", type="date", nullable=false)
- */
- protected $created;
- /**
- * @var date $updated
- *
- * @ORM\Column(name="updated", type="date", nullable=false)
- */
- protected $updated;
- public function __construct()
- {
- // may be useless
- $this->campaigns = new \Doctrine\Common\Collections\ArrayCollection();
- }
- /**
- * Magic getter to expose protected properties.
- *
- * @param string $property
- * @return mixed
- */
- public function __get($property)
- {
- return $this->$property;
- }
- /**
- * Magic setter to save protected properties.
- *
- * @param string $property
- * @param mixed $value
- */
- public function __set($property, $value)
- {
- $this->$property = $value;
- }
- /**
- * Convert the object to an array.
- *
- * @return array
- */
- public function getArrayCopy()
- {
- return get_object_vars($this);
- }
- /**
- * Populate from an array.
- *
- * @param array $data
- */
- public function populate($data = array())
- {
- //$this->id = $data['id'];
- $this->name = $data['name'];
- $this->website = $data['website'];
- $this->contact = $data['contact'];
- $this->email = $data['email'];
- $this->phone = $data['phone'];
- $this->comment = $data['comment'];
- }
- /** @ORM\PrePersist */
- public function onPrePersist()
- {
- $this->created = $this->updated = new \DateTime('now');
- }
- /** @ORM\PreUpdate */
- public function onPreUpdate()
- {
- $this->updated = new \DateTime('now');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement