<?php
namespace FMT\Data\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* UserProfile
*
* @ORM\Table(
* name="user_profile",
* indexes={
* @ORM\Index(name="FK_profile_school", columns={"school_id"}),
* @ORM\Index(name="FK_profile_major", columns={"major_id"}),
* @ORM\Index(name="FK_profile_address", columns={"address_id"}),
* @ORM\Index(name="FK_profile_avatar", columns={"avatar_id"})
* }
* )
* @UniqueEntity(
* fields={"phone"},
* message="fmt.sign_up.phone_unique", groups={"registration"}
* )
* @UniqueEntity(
* fields={"phone"},
* message="fmt.admin.phone_unique", groups={"Admin"}
* )
* @ORM\Entity
* @ORM\HasLifecycleCallbacks()
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
*/
class UserProfile implements EntityInterface
{
use TimestampableEntity;
const VISIBILITY_ALL = 0;
const VISIBILITY_REGISTRED = 1;
const VISIBILITY_NON = 2;
const GRADUATE = 'Graduate Student';
const UNDERGRADUATE = 'Undergraduate Student';
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \FMT\Data\Entity\UserSchool
*
* @ORM\ManyToOne(targetEntity="FMT\Data\Entity\UserSchool", cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="school_id", referencedColumnName="id")
* })
*/
private $school;
/**
* @var \FMT\Data\Entity\UserMajor
*
* @ORM\ManyToOne(targetEntity="FMT\Data\Entity\UserMajor", inversedBy="profile", cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="major_id", referencedColumnName="id")
* })
*/
private $major;
/**
* @var \FMT\Data\Entity\Address
*
* @ORM\ManyToOne(targetEntity="FMT\Data\Entity\Address", inversedBy="profile", cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="address_id", referencedColumnName="id")
* })
*/
private $address;
/**
* @var \FMT\Data\Entity\UserAvatar
*
* @ORM\ManyToOne(targetEntity="FMT\Data\Entity\UserAvatar", inversedBy="profile", cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="avatar_id", referencedColumnName="id")
* })
*/
private $avatar;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255, nullable=false)
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="first_name", type="string", length=255, nullable=true)
*/
private $firstName;
/**
* @var string
*
* @ORM\Column(name="last_name", type="string", length=255, nullable=true)
*/
private $lastName;
/**
* @var integer|null
*
* @ORM\Column(name="grad_year", type="integer", nullable=true)
*/
private $gradYear;
/**
* @var integer
*
* @ORM\Column(name="first_gen", type="smallint", nullable=false)
*/
private $firstGen = 0;
/**
* @var string
*
* @ORM\Column(name="student_type", type="string", length=30, nullable=true)
*/
private $studentType = self::UNDERGRADUATE;
/**
* @var string
*
* @ORM\Column(name="phone", type="string", length=30, nullable=true)
*/
private $phone;
/**
* @var string
*
* @ORM\Column(name="about", type="text", length=65535, nullable=true)
*/
private $aboutText;
/**
* @var string
*
* @ORM\Column(name="snapchat_id", type="text", length=255, nullable=true)
*/
private $snapchatId;
/**
* @var string
*
* @ORM\Column(name="facebook_messenger_id", type="text", length=255, nullable=true)
*/
private $facebookMessengerId;
/**
* @var string
*
* @ORM\Column(name="other_email", type="text", length=255, nullable=true)
*/
private $otherEmail;
/**
* @var integer
*
* @ORM\Column(name="visible", type="smallint", nullable=false)
*/
private $visible = self::VISIBILITY_ALL;
/**
* @var integer
*
* @ORM\Column(name="facebook", type="smallint", nullable=false)
*/
private $facebook = 0;
/**
* @var integer
*
* @ORM\Column(name="twitter", type="smallint", nullable=false)
*/
private $twitter = 0;
/**
* @var User
*
* @ORM\OneToOne(targetEntity="User", mappedBy="profile")
*/
protected $user;
/**
* Virtual field to fetch additional data.
*/
public function getCampaignTotal(): string
{
// Perform your custom query or logic here
// For example, fetch data from another repository or API
return ''; // Replace with actual logic
}
public function getFundedTotal(): string
{
// Perform your custom query or logic here
// For example, fetch data from another repository or API
return ''; // Replace with actual logic
}
public function getPurchaseUrl(): string
{
// Perform your custom query or logic here
// For example, fetch data from another repository or API
return ''; // Replace with actual logic
}
public function getTransferTotal(): string
{
// Perform your custom query or logic here
// For example, fetch data from another repository or API
return ''; // Replace with actual logic
}
public function getRemainingTotal(): string
{
// Perform your custom query or logic here
// For example, fetch data from another repository or API
return ''; // Replace with actual logic
}
public function getFundedPercent(): string
{
// Perform your custom query or logic here
// For example, fetch data from another repository or API
return ''; // Replace with actual logic
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return UserSchool
*/
public function getSchool()
{
return $this->school;
}
/**
* @return string
*/
public function getSnapchatId()
{
return $this->snapchatId;
}
/**
* @return string
*/
public function getFacebookMessengerId()
{
return $this->facebookMessengerId;
}
/**
* @return string
*/
public function getOtherEmail()
{
return $this->otherEmail;
}
/**
* @param string $snapchatId
* @return $this
*/
public function setSnapchatId(string $snapchatId)
{
$this->snapchatId = $snapchatId;
return $this;
}
/**
* @param string $facebookMessengerId
* @return $this
*/
public function setFacebookMessengerId(string $facebookMessengerId)
{
$this->facebookMessengerId = $facebookMessengerId;
return $this;
}
/**
* @param ?string $otherEmail
* @return $this
*/
public function setOtherEmail(?string $otherEmail)
{
$this->otherEmail = $otherEmail;
return $this;
}
/**
* @param UserSchool $school
* @return $this
*/
public function setSchool($school)
{
$this->school = $school;
return $this;
}
/**
* @return UserMajor
*/
public function getMajor()
{
return $this->major;
}
/**
* @param UserMajor $major
* @return $this
*/
public function setMajor($major)
{
$this->major = $major;
return $this;
}
/**
* @return Address
*/
public function getAddress()
{
return $this->address;
}
/**
* @param Address $address
* @return $this
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* @return UserAvatar
*/
public function getAvatar()
{
return $this->avatar;
}
/**
* @param UserAvatar $avatar
* @return $this
*/
public function setAvatar($avatar)
{
$this->avatar = $avatar;
return $this;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param string $email
* @return $this
*/
public function setEmail($email)
{
$this->email = $email;
if ($this->user) {
$this->user->syncFromProfile();
}
return $this;
}
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
* @return $this
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
return $this;
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
* @return $this
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
return $this;
}
/**
* @return int|null
*/
public function getGradYear()
{
return $this->gradYear;
}
/**
* @param int|null $gradYear
* @return $this
*/
public function setGradYear($gradYear)
{
$this->gradYear = $gradYear;
return $this;
}
/**
* @return int|null
*/
public function getfirstGen(): bool
{
return $this->firstGen;
}
/**
* @return int|null
*/
public function getfirst_gen(): bool
{
return $this->firstGen;
}
/**
* @param int|null $firstGen
* @return $this
*/
public function setfirstGen($firstGen)
{
$this->firstGen = $firstGen ? 1 : 0;
return $this;
}
/**
* @param int|null $firstGen
* @return $this
*/
public function setfirst_gen($firstGen)
{
$this->firstGen = $firstGen ? 1 : 0;
return $this;
}
/**
* @return string|null
*/
public function getStudentType(): string
{
return $this->studentType?$this->studentType:self::UNDERGRADUATE;
}
/**
* @param string|null $studentType
* @return $this
*/
public function setStudentType($studentType)
{
$this->studentType = $studentType;
return $this;
}
/**
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param string $phone
* @return $this
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* @return string
*/
public function getAboutText()
{
return $this->aboutText;
}
/**
* @param string $aboutText
* @return $this
*/
public function setAboutText($aboutText)
{
$this->aboutText = $aboutText;
return $this;
}
/**
* @return int
*/
public function getVisible()
{
return $this->visible;
}
/**
* @return bool
*/
public function isVisible()
{
return in_array($this->visible, [
self::VISIBILITY_ALL,
self::VISIBILITY_REGISTRED,
self::VISIBILITY_NON,
]);
}
/**
* @return bool
*/
public function isVisibleForAll()
{
return $this->visible == self::VISIBILITY_ALL;
}
/**
* @return bool
*/
public function isVisibleForRegisteredOnly()
{
return $this->visible == self::VISIBILITY_REGISTRED;
}
/**
* @return bool
*/
public function isInvisible()
{
return $this->visible == self::VISIBILITY_NON;
}
/**
* @param bool $visible
* @return $this
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* @return bool
*/
public function isFacebook(): bool
{
return $this->facebook;
}
/**
* @param bool $facebook
* @return $this
*/
public function setFacebook($facebook)
{
$this->facebook = $facebook ? 1 : 0;
return $this;
}
/**
* @return bool
*/
public function isTwitter(): bool
{
return $this->twitter;
}
/**
* @param bool $twitter
* @return $this
*/
public function setTwitter($twitter)
{
$this->twitter = $twitter ? 1 : 0;
return $this;
}
/**
* @return string
*/
public function getFullName()
{
return sprintf('%s %s', $this->firstName, $this->lastName);
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param User $user
* @return $this
*/
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* @return $this
*/
public function syncFromUser()
{
if ($this->user) {
$this->email = $this->user->getLogin();
}
return $this;
}
}