Created
September 20, 2011 14:56
-
-
Save codecowboy/1229314 to your computer and use it in GitHub Desktop.
User Entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Gymloop\CoreBundle\Entity; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use FOS\UserBundle\Entity\User as BaseUser; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* @ORM\Entity | |
* @ORM\Table(name="gymloop_users") | |
* @ORM\Entity(repositoryClass="Gymloop\CoreBundle\Entity\UserRepository") | |
*/ | |
class User extends BaseUser | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\generatedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\ManytoMany(targetEntity="Challenge") | |
* @ORM\JoinTable(name="users_challenges",joinColumns={@ORM\JoinColumn(name="user_id",referencedColumnName="id")}, | |
* inverseJoinColumns={@ORM\JoinColumn(name="challenge_id",referencedColumnName="id")}) | |
* | |
*/ | |
protected $challenges; | |
/** | |
* | |
* @ORM\OneToMany(targetEntity="Programme",mappedBy="user", cascade={"persist"}) | |
*/ | |
protected $programmes; | |
/** | |
* | |
* @ORM\OneToMany(targetEntity="Motivation",mappedBy="user", cascade={"persist"}) | |
*/ | |
protected $motivation; | |
/** | |
* | |
* @ORM\OneToMany(targetEntity="Gymloop\DiaryBundle\Entity\TrainingSession",mappedBy="user", cascade={"persist"}) | |
*/ | |
protected $training_sessions; | |
/** | |
* @ORM\Column(type="string", length="100",nullable="true") | |
*/ | |
protected $first_name; | |
/** | |
* @ORM\Column(type="string", length="100", nullable="true") | |
*/ | |
protected $last_name; | |
//contains count of number of confirmed sessions | |
protected $completedSessionCount; | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->programmes = new ArrayCollection(); | |
$this->challenges = new ArrayCollection(); | |
} | |
/** | |
* Get id | |
* | |
* @return integer $id | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Add programmes | |
* | |
* @param Gymloop\CoreBundle\Entity\Programme $programmes | |
*/ | |
public function addProgrammes(\Gymloop\CoreBundle\Entity\Programme $programmes) | |
{ | |
$this->programmes[] = $programmes; | |
$programmes->setUser($this); | |
} | |
/** | |
* Get programmes | |
* | |
* @return Doctrine\Common\Collections\Collection $programmes | |
*/ | |
public function getProgrammes() | |
{ | |
return $this->programmes; | |
} | |
/** | |
* Add training_sessions | |
* | |
* @param Gymloop\DiaryBundle\Entity\TrainingSession $trainingSessions | |
*/ | |
public function addTrainingSessions(\Gymloop\DiaryBundle\Entity\TrainingSession $trainingSessions) | |
{ | |
$this->training_sessions[] = $trainingSessions; | |
} | |
/** | |
* Get training_sessions | |
* | |
* @return Doctrine\Common\Collections\Collection | |
*/ | |
public function getTrainingSessions() | |
{ | |
return $this->training_sessions; | |
} | |
/** | |
* Set first_name | |
* | |
* @param string $firstName | |
*/ | |
public function setFirstName($firstName) | |
{ | |
$this->first_name = $firstName; | |
} | |
/** | |
* Get first_name | |
* | |
* @return string | |
*/ | |
public function getFirstName() | |
{ | |
return $this->first_name; | |
} | |
/** | |
* Set last_name | |
* | |
* @param string $lastName | |
*/ | |
public function setLastName($lastName) | |
{ | |
$this->last_name = $lastName; | |
} | |
/** | |
* Get last_name | |
* | |
* @return string | |
*/ | |
public function getLastName() | |
{ | |
return $this->last_name; | |
} | |
/** | |
* Add motivation | |
* | |
* @param Gymloop\CoreBundle\Entity\Motivation $motivation | |
*/ | |
public function addMotivation(\Gymloop\CoreBundle\Entity\Motivation $motivation) | |
{ | |
$this->motivation[] = $motivation; | |
} | |
/** | |
* Get motivation | |
* | |
* @return Doctrine\Common\Collections\Collection | |
*/ | |
public function getMotivation() | |
{ | |
return $this->motivation; | |
} | |
public function addSingleMotivation(Array $motivation) | |
{ | |
$this->motivation = $motivation; | |
} | |
public function setCompletedSessionCount($count) | |
{ | |
$this->completedSessionCount = $count; | |
} | |
function getCompletedSessionCount() | |
{ | |
return $this->completedSessionCount; | |
} | |
/** | |
* Add challenges | |
* | |
* @param Gymloop\CoreBundle\Entity\Challenge $challenges | |
*/ | |
public function addChallenges(\Gymloop\CoreBundle\Entity\Challenge $challenges) | |
{ | |
$this->challenges[] = $challenges; | |
} | |
/** | |
* Get challenges | |
* | |
* @return Doctrine\Common\Collections\Collection | |
*/ | |
public function getChallenges() | |
{ | |
return $this->challenges; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment