I have added a select form above the calendar to select an user and show his events(entity booking for example)on the Fullcalendar
so my question is, how the data of
You should create a select of your users and do something like this
$('#users').on('change', function() {
var userId = this.value;
$('#calendar-holder').fullCalendar({
eventSources: [{
url: "{{ path('fullcalendar_load_events') }}",
type: 'POST',
data: {
filters: {
user_id: userId,
}
},
error: function () {
alert('There was an error while fetching FullCalendar!');
}
}]
});
$('#calendar-holder').fullCalendar('refetchEvents');
});
in your listener you can now update the query accordingly
$bookings = $this->em->getRepository(Booking::class)
->createQueryBuilder('booking')
->where('booking.beginAt BETWEEN :startDate and :endDate')
->innerJoin('booking.user', 'user')
->andWhere('user.id = :userId')
->setParameter('userId', $filters['user_id'])
->setParameter('startDate', $startDate->format('Y-m-d H:i:s'))
->setParameter('endDate', $endDate->format('Y-m-d H:i:s'))
->getQuery()->getResult();