Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

470
Vistas
How to display multiple JSON values in full calendar?

I am currently displaying a single JSON object value in the full calendar. I need to display the second JSON object as well.

<script>
$(document).ready(function(){
    var booking_details  = @json($booking_details);

    // I need to display these json values also
    var test  = @json($test);
    

    $("#calander").fullCalendar({
      events: booking_details,
      eventColor: '#FF0000'
    }); 
});
</script>

This is the controller in Laravel:

$booking_details = array();
$bookings = Booking::all();
   
foreach ($bookings as $booking) {

    $booking_details[] = [
       'title'=>$booking->room_number,
       'start'=>$booking->checkin_date,
       'end'=>$booking->checkout_date
    ];
}

// this is testing purpose
$test = array();

foreach ($bookings as $booking) {
   $test[] = [
       'title'=>$booking->room_number,
       'start'=>$booking->checkin_date,
       'end'=>$booking->checkout_date
   ];
}

I'm sending the same data with a different JSON name. I only need how to display multiple JSON object values in the same calendar.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Then you need to add the two arrays of events.

$("#calander").fullCalendar({
    events: booking_details.concat(test),
    eventColor: '#FF0000'
}); 
about 4 years ago · Juan Pablo Isaza Denunciar

0

Why not just add all the data to the $booking_details array in the PHP code? But also, $test just contains the exact same data as booking_details, so what's the point? Maybe that's just a poor example in the question, I can't tell?

But anyway if you have two separate sources of data you want to supply as events, you can either

  1. use one array in PHP as I suggested above, or

  2. concatenate them in JavaScript as IT goldman's answer shows, or

  3. you can have them as two separate event feeds, which you can set up in fullCalendar via the eventSources option, e.g.

$("#calander").fullCalendar({
  eventSources: [
    {
      "events": booking_details,
      "color": "red"
    },
    {
      "events": test,
      "color": "blue"
    }
  ],
}); 
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda