Display child with JSON

HEllo people,

After a lot of research, I decided to ask you for help.
I am developing a calendar using “dhtmlx scheduler” in the laravel framework.
I am trying to list all fields from the Events table that is related to the Users table.

In ControllerEvent have:

    $events = Event::all();

    return response()->json([
        "data" => $events->all()
    ]);

The array data is keeping everything right, but when it comes time to show I can’t display what I want.

{ name:“Cliente”, height:50, type:“textarea”, map_to:“user_id”, focus:true }

If you let it, it will show me the user id. But I wanted to show the name of this user. It must be something like (map_to:“user_id.name”) ou (map_to:“user_id[1]”)?

If someone can give me a little help thank you :smiley:

Hello,

If you want to use a textarea, I think the only way is to map it to a dynamic property that will hold the user name.
You can populate this property right before the lightbox is displayed:

config:

{ name:"Cliente", height:50, type:"textarea", map_to:"user_name", focus:true }

code:

scheduler.attachEvent("onBeforeLightbox", function (id){
    var event = scheduler.getEvent(id);

    // getUserNameById - a function you'll need to implement
    event.user_name = getUserNameById(event.user_id);
    return true;
});

https://docs.dhtmlx.com/scheduler/api__scheduler_onbeforelightbox_event.html