与symfony 3相似的按钮/不喜欢的按钮

时间:2018-11-23 10:07:29

标签: ajax symfony button

我在我的患者空间中有他与之约会的医生名单。我想在每位医生旁边添加一个我喜欢的按钮,以便患者可以告诉他他是否愿意接受咨询医生。 我想知道喜欢给定医生的患者数量。要在医生的详细信息中显示此号码。

这是我的控制人,那里有我的医生清单

控制器

 public function patientBookingListAction(Request $request)
{

    $em  = $this->getDoctrine()->getManager();

    $medecin = $em->getRepository("DoctixMedecinBundle:Medecin")->findOneBy(array(
        'user' => $this->getUser(),
    ));

    $patient = $em->getRepository("DoctixPatientBundle:Patient")->findOneBy(array(
        'user' => $this->getUser(),
    ));

    $bookings = $em->getRepository("DoctixFrontBundle:Booking")->findBy(array(
        "patient" => $patient
    ));

    $bookings = $this->get('knp_paginator')->paginate($bookings, $request->query->get('page', 1), 3);


    return $this->render('DoctixPatientBundle:Patient:bookings.html.twig', array(
        'bookings' => $bookings
    ));
}

我已经创建了我的表favorite_doctor:

实体favorite_doctor

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


/**
 * @ORM\ManyToOne(targetEntity="Doctix\PatientBundle\Entity\Patient", inversedBy="medecin_favoris")
 * @ORM\JoinColumn(name="patient_id", referencedColumnName="id")
 */
private $patient;

   /**
 * @ORM\ManyToOne(targetEntity="Doctix\MedecinBundle\Entity\Medecin", inversedBy="medecin_favoris")
 * @ORM\JoinColumn(name="medecin_id", referencedColumnName="id")
 */
private $medecin;



/**
 * Get id
 *
 * @return integer
 */
public function getId()
{
    return $this->id;
}

/**
 * Set patient
 *
 * @param \Doctix\PatientBundle\Entity\Patient $patient
 *
 * @return MedecinFavoris
 */
public function setPatient(\Doctix\PatientBundle\Entity\Patient $patient = null)
{
    $this->patient = $patient;

    return $this;
}

/**
 * Get patient
 *
 * @return \Doctix\PatientBundle\Entity\Patient
 */
public function getPatient()
{
    return $this->patient;
}

/**
 * Set medecin
 *
 * @param \Doctix\MedecinBundle\Entity\Medecin $medecin
 *
 * @return MedecinFavoris
 */
public function setMedecin(\Doctix\MedecinBundle\Entity\Medecin $medecin = null)
{
    $this->medecin = $medecin;

    return $this;
}

/**
 * Get medecin
 *
 * @return \Doctix\MedecinBundle\Entity\Medecin
 */
public function getMedecin()
{
    return $this->medecin;
}
 }

当我单击按钮时,我希望将数据保存在此表中。

树枝

  {% for booking in bookings %}
        <div class="list_general" id="liste">
            <a href="#0" class="wish_bt"></a>
            <ul>
                <li>
                    <figure><img src="{{ vich_uploader_asset(booking.medecin.media, 'imageFile') }}"
                                                         alt="{{ booking.medecin.media.imagename }}"></figure>
                    <h4>Dr. {{ booking.medecin.user.prenom|capitalize }} {{ booking.medecin.user.nom|upper }} <i class="pending">Pending</i></h4>
                     <ul class="booking_details">
                        <li><strong>Date et heure</strong>{{ booking.dateHeureRdv|date('d/m/Y') }}</li>
                        <li><strong>Heure</strong>{{ booking.dateHeureRdv|date('H:i') }}</li>
                        <li><strong>Motif</strong>Consultation</li>
                        <li><strong>Téléphone</strong>{{ booking.medecin.user.numTel }}</li>
                        <li><strong>Email</strong>{{ booking.medecin.user.username }}</li>
                    </ul>
                    <ul class="buttons">
                        <li><a href="{{ path('patient_booking_deplacer', {'id': booking.id}) }}?medecin={{ booking.medecin.id }}" class="btn_1 gray approve"><i class="fa fa-fw fa-check-circle-o"></i> Déplacer Rdv</a></li>
                        <li><a href="{{ path('patient_booking_annuler', {'id': booking.id}) }}" class="btn_1 gray delete"><i class="fa fa-fw fa-times-circle-o"></i> Annuler</a></li>
                    </ul>
                </li>
                <div class="like">
                <a href="#" class="fa fa fa-thumbs-up">Like</a>
                </div>  
                </ul>

        </div>
    {% endfor %}    

现在,当我单击“赞”按钮时,我不知道该怎么办。知道患者需要时,数据必须在数据库中注册,并且“喜欢”按钮也必须消失,以不再允许他投票两次或更多次。

非常感谢

0 个答案:

没有答案
相关问题