如何在symfony 3中制作简单的星星符号

时间:2018-11-15 19:06:37

标签: javascript symfony rating-system

晚上好,我尝试让患者注意所咨询的医生,以便在寻找医生之后,最引人注意的地方首先出现。但是在这里我不知道该怎么做。首先,我向我的实体添加了表决属性。

实体

  class Medecin
 {
/**
 * @var int
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="sexe", type="string", length=40)
 */
public $sexe;

/**
 * @var int
 *
 * @ORM\Column(name="note", type="integer")
 */
private $note = 0;

}

这是我的树枝文件,我也在其中显示带有星星的医生数据:

树枝

 <span class="rating">
                                {% for i in 1..5 %}
                                    <i class="icon_star {{ medecin.note >= (i * 20) ? 'voted' : ''}}"></i>
                                {% endfor %}
                        | <small>  <strong>{{ medecin.note }}</strong></small>
                    </span>

CSS

.rating i {
  color: #ddd;
  font-size: 13px;
  font-size: 0.8125rem;
}
.rating i.voted {
  color: #FFC107;
}
.rating small {
  margin-bottom: 0;
  display: inline-block;
  font-size: 12px;
  font-size: 0.75rem;
}
.rating small a {
  color: #999;
  text-decoration: underline;
}

我的问题是,当我飞越星星时,没有动作发生。然后,当患者单击投票数并将他的投票记录给附属医生时,如何记录投票? 谢谢

1 个答案:

答案 0 :(得分:0)

请以英文而不是法语,荷兰语或中文编码。选择英语作为您的代码库。

您需要具有评级实体:

医生

class Doctor
{
    // ...

    /**
     * @ORM\OneToMany(targetEntity=“Rating”, mappedBy=“doctor”)
     */
    protected $ratings;

    // ...
}

评分

class Rating
{
    // ...

    /**
     * @ORM\Column(type=“integer”, name=“value”)
     */
    protected $value;

    /**
     * @ORM\ManyToOne(targetEntity=“Doctor”, inversedBy=“ratings”)
     */
    protected $doctor;

    /**
     * @ORM\ManyToOne(targetEntity=“Patient”, inversedBy=“ratings”)
     */
    protected $patient;

    // ...
}

患者

class Patient
{
    // ...

    /**
     * @ORM\OneToMany(targetEntity=“Rating”, mappedBy=“patient”, cascade={“persist”, “remove”})
     */
    protected $ratings;

    // ...
}