Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Entities;
- use \Doctrine\ORM\Mapping as ORM;
- use \Doctrine\Common\Collections\ArrayCollection as ArrayCollection;
- /**
- * @ORM\HasLifeCycleCallbacks
- * @ORM\Entity
- * @ORM\Table(name="player")
- */
- class Player {
- /**
- * @ORM\Id
- * @ORM\Column(type="integer", nullable=false)
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORM\Column(type="string", length="255", nullable=false)
- */
- protected $name;
- /**
- * @ORM\Column(type="integer", length="1", nullable=false)
- */
- protected $is_gk = 0;
- /**
- * @ORM\Column(type="datetime", nullable=false)
- */
- protected $cdate;
- /**
- * @ORM\Column(type="datetime", nullable=false)
- */
- protected $mdate;
- /**
- * @ORM\ManyToOne(targetEntity="Club", inversedBy="players")
- * @ORM\JoinColumn(name="club_id", referencedColumnName="id")
- * @var Club
- */
- protected $club;
- public function __construct()
- {
- $this->club = new ArrayCollection();
- $this->cdate = new DateTime();
- }
- // GETTERS & SETTERS
- public function getId()
- {
- return $this->id;
- }
- public function setName($name) {
- $this->name = $name;
- }
- public function getName() {
- return $this->name;
- }
- public function setGk($is_gk) {
- $this->is_gk = (int)$is_gk;
- }
- public function getGk() {
- return $this->is_gk;
- }
- /** @PrePersist */
- public function setCdate()
- {
- $this->cdate = new DateTime("now");
- }
- public function getCdate() {
- return $this->cdate;
- }
- public function setMdate($date) {
- $this->mdate = $date;
- }
- public function getMdate() {
- return $this->mdate;
- }
- public function setClub(Club $club)
- {
- if( $club === null || $club instanceof Club ) {
- $this->club = $club;
- } else {
- throw new InvalidArgumentException($club . ' must be instance of Entity\Club or null');
- }
- }
- public function getClub()
- {
- return $this->club;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement