Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

469
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!