<?php
// vim: set ts=4 sw=4 sts=4 et:
/**
* Testimonials Module
*
* @category X-Cart_5_5_Module
* @package Testimonials
* @author CFL Systems, Inc. <support@cflsystems.com>
* @copyright 2022 CFL Systems, Inc. All rights reserved.
* @license License Agreement - https://www.cflsystems.com/software-license-agreement.html
* @link https://www.cflsystems.com/testimonials-for-x-cart-5.html
*/
namespace CSI\Testimonials\Model;
use XLite\Model\Profile;
use XLite\Core\Converter;
use Doctrine\ORM\Mapping as ORM;
/**
* The "testimonials" model class
*
* @ORM\Entity
* @ORM\Table (name="csi_testimonials")
*/
class Testimonial extends \XLite\Model\AEntity
{
/**
* Entry unique ID
*
* @var integer
*
* @ORM\Id
* @ORM\GeneratedValue (strategy="AUTO")
* @ORM\Column (type="integer")
*/
protected $id;
/**
* Customer name
*
* @var string
*
* @ORM\Column (type="string", length=32)
*/
protected $name;
/**
* Customer email
*
* @var string
*
* @ORM\Column (type="string", length=128)
*/
protected $email;
/**
* The profile id
*
* @var Profile
*
* @ORM\ManyToOne (targetEntity="XLite\Model\Profile", inversedBy="testimonials")
* @ORM\JoinColumn (name="profile_id", referencedColumnName="profile_id")
*/
protected $profile;
/**
* Testimonial title
*
* @var string
*
* @ORM\Column (type="string", length=255)
*/
protected $title;
/**
* Customer location
*
* @var string
*
* @ORM\Column (type="string", length=255)
*/
protected $location;
/**
* Testimonial date
*
* @var integer
*
* @ORM\Column (type="integer")
*/
protected $date = 0;
/**
* Testimonial text
*
* @var text
*
* @ORM\Column (type="text")
*/
protected $testimonial;
/**
* Remote ip2long
*
* @var integer
*
* @ORM\Column (type="bigint")
*/
protected $ip = 0;
/**
* Status
* P - Pending
* D - Declined
* A - Approved
*
* @var string
*
* @ORM\Column (type="string", length=1, options={ "default": "P" })
*/
protected $status = 'P';
/**
* Is testimonial visible or not
*
* @var boolean
*
* @ORM\Column (type="boolean")
*/
protected $enabled = true;
/**
* Prepare date
*
* @return void
*
* @ORM\PrePersist
*/
public function prepareBeforeCreate()
{
if (!$this->getDate()) {
$this->setDate(Converter::time());
}
}
/**
* Map data to entity columns
*
* @param array $data Array of data
*
* @return self
*/
public function map(array $data)
{
$data = array_filter($data, function ($name) {
return $this->isPropertyExists($name);
}, ARRAY_FILTER_USE_KEY);
return parent::map($data);
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return self
*/
public function setName(string $name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set email
*
* @param string $email
*
* @return self
*/
public function setEmail(string $email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set title
*
* @param string $title
*
* @return self
*/
public function setTitle(string $title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set location
*
* @param string $location
*
* @return self
*/
public function setLocation(string $location)
{
$this->location = $location;
return $this;
}
/**
* Get location
*
* @return string
*/
public function getLocation()
{
return $this->location;
}
/**
* Set date
*
* @param integer $date
*
* @return self
*/
public function setDate(int $date)
{
$this->date = (int) $date;
return $this;
}
/**
* Get date
*
* @return integer
*/
public function getDate()
{
return $this->date;
}
/**
* Set testimonial
*
* @param text $testimonial
*
* @return self
*/
public function setTestimonial(string $testimonial)
{
$this->testimonial = $testimonial;
return $this;
}
/**
* Get testimonial
*
* @return text
*/
public function getTestimonial()
{
return $this->testimonial;
}
/**
* Set ip
*
* @param bigint $ip
*
* @return self
*/
public function setIp($ip)
{
$this->ip = $ip;
return $this;
}
/**
* Get ip
*
* @return bigint
*/
public function getIp()
{
return $this->ip;
}
/**
* Set status
*
* @param string $status
*
* @return self
*/
public function setStatus(string $status)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* Set enabled
*
* @param boolean $enabled
*
* @return self
*/
public function setEnabled(bool $enabled)
{
$this->enabled = (bool) $enabled;
return $this;
}
/**
* Get enabled
*
* @return boolean
*/
public function getEnabled()
{
return $this->enabled;
}
/**
* Set profile
*
* @param Profile $profile
*
* @return self
*/
public function setProfile(Profile $profile = null)
{
$this->profile = $profile;
return $this;
}
/**
* Get profile
*
* @return Profile
*/
public function getProfile()
{
return $this->profile;
}
}