<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Util\TokenGenerator;
/**
* @ORM\Entity(repositoryClass="App\Repository\ParticipantRepository")
*/
class Participant {
const PAYMENT_STATUS_PENDING = 'pending';
const PAYMENT_STATUS_PROCESSING = 'processing';
const PAYMENT_STATUS_PAID = 'paid';
const PAYMENT_STATUS_FAILED = 'failed';
const PAYMENT_STATUS_REFUNDED = 'refunded';
/**
* @var integer The id of the participant
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Competition", inversedBy="participants")
* @ORM\JoinColumn(name="competition_id", referencedColumnName="id", nullable=false)
*/
private $competition;
/**
* @var string The name of the participant
* @ORM\Column(name="full_name", type="string", length=100)
*/
private $name;
/**
* @var string The name of the team
* @ORM\Column(name="team_name", type="string", length=100)
*/
private $teamName;
/**
* @var string The email of the participant
* @ORM\Column(type="string", length=100)
*/
private $email;
/**
* @var string The phone number of the participant
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $phoneNumber;
/**
* @ORM\Column(name="message", type="text", nullable=true)
*/
private $message;
/**
* @ORM\Column(name="down_payment_amount", type="integer", nullable=false)
*/
private $downPaymentAmount;
/**
* @var string The unique hash identifier of the user
* @ORM\Column(name="hash", type="string", length=20, unique=true)
*/
private $hash;
/**
* @ORM\Column(name="payment_status", type="string", length=25, nullable=false)
*/
private $paymentStatus = self::PAYMENT_STATUS_PENDING;
/**
* @ORM\Column(name="payment_message", type="string", length=255, nullable=true)
*/
private $paymentMessage;
/**
* @ORM\Column(name="charge_id", type="string", length=50, nullable=true)
*/
private $chargeId;
/**
* @var \DateTime
* @ORM\Column(type="datetime", name="created_at")
*/
private $createdAt;
public function __construct() {
$this->createdAt = new \DateTime();
$this->hash = TokenGenerator::generateToken(7);
}
public function __toString() {
return (string) $this->getName();
}
public function getId() {
return $this->id;
}
public function getCompetition() {
return $this->competition;
}
public function setCompetition($competition) {
$this->competition = $competition;
return $this;
}
public function getName() {
return $this->name;
}
public function setName($name) {
$this->name = $name;
return $this;
}
public function getTeamName() {
return $this->teamName;
}
public function setTeamName($teamName) {
$this->teamName = $teamName;
return $this;
}
public function getEmail() {
return $this->email;
}
public function setEmail($email) {
$this->email = $email;
return $this;
}
public function getPhoneNumber() {
return $this->phoneNumber;
}
public function setPhoneNumber($phoneNumber) {
$this->phoneNumber = $phoneNumber;
return $this;
}
public function getMessage() {
return $this->message;
}
public function setMessage($message) {
$this->message = $message;
return $this;
}
public function getDownPaymentAmount() {
return $this->downPaymentAmount;
}
public function setDownPaymentAmount($downPaymentAmount) {
$this->downPaymentAmount = $downPaymentAmount;
return $this;
}
public function getHash() {
return $this->hash;
}
public function setHash($hash) {
$this->hash = $hash;
return $this;
}
public function getPaymentStatus() {
return $this->paymentStatus;
}
public function getPaymentMessage() {
return $this->paymentMessage;
}
public function getChargeId() {
return $this->chargeId;
}
public function setPaymentStatus($paymentStatus) {
$this->paymentStatus = $paymentStatus;
return $this;
}
public function setPaymentMessage($paymentMessage) {
$this->paymentMessage = $paymentMessage;
return $this;
}
public function setChargeId($chargeId) {
$this->chargeId = $chargeId;
return $this;
}
public function getCreatedAt(): \DateTime {
return $this->createdAt;
}
public function setCreatedAt(\DateTime $createdAt) {
$this->createdAt = $createdAt;
return $this;
}
public function isPaymentPaid() {
return $this->paymentStatus === self::PAYMENT_STATUS_PAID;
}
public function isPaymentPending() {
return $this->paymentStatus === self::PAYMENT_STATUS_PENDING;
}
}