Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

palla451's avatar

FullCalendar Booking

Hy all, i have this problem:

I want the view of this example : https://fullcalendar.io/releases/fullcalendar-scheduler/1.9.4/demos/json.html

in this example i have the json file resource end event

Events: [ { id: "1", resourceId: "b", start: "2018-04-07T02:00:00", end: "2018-04-07T07:00:00", title: "event 1" } ]

and

Resource: [ { id: "1", title: "resource 1" }, ]

In my project i have

Events: [ { id: 1, resourceId: 1, start: "2018-04-07T02:00:00", end: "2018-04-07T07:00:00", title: "event 1" } ]

and

Resource: [ { id: 1, title: "resource 1" }, ]

In my project id and resourceId as integer value and for this the fullcalendar don't show the events.

how can i solve it, please...

Thank you all...

0 likes
2 replies
peterbrinck's avatar

You need to show us some of your code and how you implemented FullCalendar

palla451's avatar

Hi @peterbrinck thanks

this is my FullCalendarController

Hi @peterbrinck , this is my FullCalendarController:

Controller:

public static function getBookingByRoomId($id)
{
    $booking = Booking::where('room_id', '=', $id)
                        ->orderBy('start_date')
                        ->get([
                            'booked_by',
                            'start_date',
                            'end_date',
                        ]);

    return $booking->map(function($event) {
        $booking['title'] = 'Booked by ' . $event->user->name;
        $booking['start'] = $event->start_date->toDateTimeString();
        $booking['end'] = $event->end_date->toDateTimeString();
        return $booking;
    });
}


public static function getBookingAllRoom()
{
    $booking = Booking::orderBy('start_date')
        ->get([
            'id',
            'room_id',
            'booked_by',
            'start_date',
            'end_date',
        ]);
//    return $booking;

    return $booking->map(function($event) {
        $booking['id'] = $event->room_id;
        $booking['resourceId'] = $event->room_id;
        $booking['start'] = $event->start_date->toDateTimeString();
        $booking['end'] = $event->end_date->toDateTimeString();
        $booking['title'] = $event->user->name;
        return $booking;
    });
}


public static function getRoomAll()
{
    $room = Room::all();

    return $room->map(function($event) {
        $room['id'] = $event->id;
        $room['title'] = $event->name;
        $room['eventColor'] = 'red';
        return $room;
    });
}

Route:

Route::get('bookings/all', 'FullcalendarController@getBookingAllRoom')->name('fullcalendar.bookingall');

Route::get('rooms/all', 'FullcalendarController@getRoomAll')->name('fullcalendar.roomall');

Route::get('/fullcalendar', function () { return view('dashboard.rooms-all'); });

Rooms-all.blade.php:

<style>

    body {
        margin: 0;
        padding: 0;
        font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
        font-size: 14px;
    }

    #calendar {
        max-width: 1024px;
        margin: 50px auto;
    }

</style>
$(function() {
    $('#calendar').fullCalendar({
        now: new Date(),
        editable: false,
        aspectRatio: 1.8,
        scrollTime: '06:00', 
        defaultView: 'timelineDay',
        views: {
            timelineThreeDays: {
                type: 'timeline',
                duration: { days: 3 }
            }
        },
        resourceLabelText: 'Rooms',
        resources: '{!! route('fullcalendar.roomall') !!}',
    // if active events it's no work
        // events: '{!! route('fullcalendar.bookingall') !!}'
        events: [
            {
                id: "1",
                resourceId: "1",
                start: "2018-06-27 09:00:00",
                end: "2018-06-27 12:00:00",
                title: "title1",
            },
            {
                id: "2",
                resourceId: "1",
                start: "2018-06-27 15:00:00",
                end: "2018-06-27 19:00:00",
                title: "title2",
            }
        ]
    });
});

Please or to participate in this conversation.