button like/dislike with symfony 3
I have in my patient space, a list of doctors with whom he has made an appointment.And next to each doctor, I want to add a button I like so that the patient can tell if he liked or not the consultation with the doctor.
And I would like to know the number of patients who have liked a given doctor. For this number to be displayed in the doctor's details.
Here is my controller where I have my list of doctors
Controller
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
));
}
I had already create my table favorite_doctor :
Entity favorite_doctor
class MedecinFavoris
{
/**
* @var int
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORMManyToOne(targetEntity="DoctixPatientBundleEntityPatient", inversedBy="medecin_favoris")
* @ORMJoinColumn(name="patient_id", referencedColumnName="id")
*/
private $patient;
/**
* @ORMManyToOne(targetEntity="DoctixMedecinBundleEntityMedecin", inversedBy="medecin_favoris")
* @ORMJoinColumn(name="medecin_id", referencedColumnName="id")
*/
private $medecin;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set patient
*
* @param DoctixPatientBundleEntityPatient $patient
*
* @return MedecinFavoris
*/
public function setPatient(DoctixPatientBundleEntityPatient $patient = null)
{
$this->patient = $patient;
return $this;
}
/**
* Get patient
*
* @return DoctixPatientBundleEntityPatient
*/
public function getPatient()
{
return $this->patient;
}
/**
* Set medecin
*
* @param DoctixMedecinBundleEntityMedecin $medecin
*
* @return MedecinFavoris
*/
public function setMedecin(DoctixMedecinBundleEntityMedecin $medecin = null)
{
$this->medecin = $medecin;
return $this;
}
/**
* Get medecin
*
* @return DoctixMedecinBundleEntityMedecin
*/
public function getMedecin()
{
return $this->medecin;
}
}
I would like that when I click on the button like that my data is saved in this table.
Twig
{% 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 %}
Now i do not know exactly what to do when i click the like button. Knowing that when a patient like, the data must register in the database and the like button must also disappear to no longer allow him to vote two or more times.
Thanks a lot
ajax symfony button
add a comment |
I have in my patient space, a list of doctors with whom he has made an appointment.And next to each doctor, I want to add a button I like so that the patient can tell if he liked or not the consultation with the doctor.
And I would like to know the number of patients who have liked a given doctor. For this number to be displayed in the doctor's details.
Here is my controller where I have my list of doctors
Controller
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
));
}
I had already create my table favorite_doctor :
Entity favorite_doctor
class MedecinFavoris
{
/**
* @var int
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORMManyToOne(targetEntity="DoctixPatientBundleEntityPatient", inversedBy="medecin_favoris")
* @ORMJoinColumn(name="patient_id", referencedColumnName="id")
*/
private $patient;
/**
* @ORMManyToOne(targetEntity="DoctixMedecinBundleEntityMedecin", inversedBy="medecin_favoris")
* @ORMJoinColumn(name="medecin_id", referencedColumnName="id")
*/
private $medecin;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set patient
*
* @param DoctixPatientBundleEntityPatient $patient
*
* @return MedecinFavoris
*/
public function setPatient(DoctixPatientBundleEntityPatient $patient = null)
{
$this->patient = $patient;
return $this;
}
/**
* Get patient
*
* @return DoctixPatientBundleEntityPatient
*/
public function getPatient()
{
return $this->patient;
}
/**
* Set medecin
*
* @param DoctixMedecinBundleEntityMedecin $medecin
*
* @return MedecinFavoris
*/
public function setMedecin(DoctixMedecinBundleEntityMedecin $medecin = null)
{
$this->medecin = $medecin;
return $this;
}
/**
* Get medecin
*
* @return DoctixMedecinBundleEntityMedecin
*/
public function getMedecin()
{
return $this->medecin;
}
}
I would like that when I click on the button like that my data is saved in this table.
Twig
{% 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 %}
Now i do not know exactly what to do when i click the like button. Knowing that when a patient like, the data must register in the database and the like button must also disappear to no longer allow him to vote two or more times.
Thanks a lot
ajax symfony button
add a comment |
I have in my patient space, a list of doctors with whom he has made an appointment.And next to each doctor, I want to add a button I like so that the patient can tell if he liked or not the consultation with the doctor.
And I would like to know the number of patients who have liked a given doctor. For this number to be displayed in the doctor's details.
Here is my controller where I have my list of doctors
Controller
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
));
}
I had already create my table favorite_doctor :
Entity favorite_doctor
class MedecinFavoris
{
/**
* @var int
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORMManyToOne(targetEntity="DoctixPatientBundleEntityPatient", inversedBy="medecin_favoris")
* @ORMJoinColumn(name="patient_id", referencedColumnName="id")
*/
private $patient;
/**
* @ORMManyToOne(targetEntity="DoctixMedecinBundleEntityMedecin", inversedBy="medecin_favoris")
* @ORMJoinColumn(name="medecin_id", referencedColumnName="id")
*/
private $medecin;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set patient
*
* @param DoctixPatientBundleEntityPatient $patient
*
* @return MedecinFavoris
*/
public function setPatient(DoctixPatientBundleEntityPatient $patient = null)
{
$this->patient = $patient;
return $this;
}
/**
* Get patient
*
* @return DoctixPatientBundleEntityPatient
*/
public function getPatient()
{
return $this->patient;
}
/**
* Set medecin
*
* @param DoctixMedecinBundleEntityMedecin $medecin
*
* @return MedecinFavoris
*/
public function setMedecin(DoctixMedecinBundleEntityMedecin $medecin = null)
{
$this->medecin = $medecin;
return $this;
}
/**
* Get medecin
*
* @return DoctixMedecinBundleEntityMedecin
*/
public function getMedecin()
{
return $this->medecin;
}
}
I would like that when I click on the button like that my data is saved in this table.
Twig
{% 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 %}
Now i do not know exactly what to do when i click the like button. Knowing that when a patient like, the data must register in the database and the like button must also disappear to no longer allow him to vote two or more times.
Thanks a lot
ajax symfony button
I have in my patient space, a list of doctors with whom he has made an appointment.And next to each doctor, I want to add a button I like so that the patient can tell if he liked or not the consultation with the doctor.
And I would like to know the number of patients who have liked a given doctor. For this number to be displayed in the doctor's details.
Here is my controller where I have my list of doctors
Controller
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
));
}
I had already create my table favorite_doctor :
Entity favorite_doctor
class MedecinFavoris
{
/**
* @var int
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORMManyToOne(targetEntity="DoctixPatientBundleEntityPatient", inversedBy="medecin_favoris")
* @ORMJoinColumn(name="patient_id", referencedColumnName="id")
*/
private $patient;
/**
* @ORMManyToOne(targetEntity="DoctixMedecinBundleEntityMedecin", inversedBy="medecin_favoris")
* @ORMJoinColumn(name="medecin_id", referencedColumnName="id")
*/
private $medecin;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set patient
*
* @param DoctixPatientBundleEntityPatient $patient
*
* @return MedecinFavoris
*/
public function setPatient(DoctixPatientBundleEntityPatient $patient = null)
{
$this->patient = $patient;
return $this;
}
/**
* Get patient
*
* @return DoctixPatientBundleEntityPatient
*/
public function getPatient()
{
return $this->patient;
}
/**
* Set medecin
*
* @param DoctixMedecinBundleEntityMedecin $medecin
*
* @return MedecinFavoris
*/
public function setMedecin(DoctixMedecinBundleEntityMedecin $medecin = null)
{
$this->medecin = $medecin;
return $this;
}
/**
* Get medecin
*
* @return DoctixMedecinBundleEntityMedecin
*/
public function getMedecin()
{
return $this->medecin;
}
}
I would like that when I click on the button like that my data is saved in this table.
Twig
{% 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 %}
Now i do not know exactly what to do when i click the like button. Knowing that when a patient like, the data must register in the database and the like button must also disappear to no longer allow him to vote two or more times.
Thanks a lot
ajax symfony button
ajax symfony button
asked Nov 23 at 10:07
Mohamed Sacko
549
549
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444575%2fbutton-like-dislike-with-symfony-3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444575%2fbutton-like-dislike-with-symfony-3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown