api.emotionhero.com/src/Models/Target.php
2016-09-04 12:05:09 +01:00

79 lines
1.7 KiB
PHP

<?php
namespace EmotionHero\Models;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Users
*
* @ORM\Table(name="targets",uniqueConstraints={
* @ORM\UniqueConstraint(name="level_position", columns={"level_id", "position"})})
* })
* @ORM\Entity
*/
class Target
{
/**
* @var integer
*
* @ORM\Column(name="id",type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* Incremental position in level
* @var int
* @ORM\Column
*/
private $position;
/**
* @ORM\ManyToOne(targetEntity="Level", inversedBy="targets", cascade={"persist"})
* @ORM\JoinColumn(name="level_id", referencedColumnName="id", nullable=false)
*/
private $level;
/**
* @var float
* @ORM\Column
*/
private $time;
/**
* @ORM\ManyToOne(targetEntity="Emotion", inversedBy="targets")
* @ORM\JoinColumn(name="emotion_id", referencedColumnName="id", nullable=false)
*/
private $emotion;
/**
* Required score
* @var int
* @ORM\Column
*/
private $score;
/**
* @JMS\Exclude
* @ORM\OneToMany(targetEntity="Hit", mappedBy="target", fetch="EXTRA_LAZY")
*/
private $hits;
public function __construct(Level $level, int $position, Emotion $emotion, int $score, float $time)
{
$this->hits = new ArrayCollection();
$this->level = $level;
$this->emotion = $emotion;
$this->score = $score;
$this->time = $time;
$this->position = $position;
}
public function addHit(Hit $hit){
$this->hits->add($hit);
}
}