I want to show user name that user has booked to slot on calender and i have already made relation how can i show username please help me thanks.
Booking Model
public function users(){
return $this->hasOne('App\Models\User','id','user_id');
}
Controller
public function getBookingSlot(Request $request){
$userBookings = Booking::with('users')->where('room_id',$request->room_id)->where('booking_holding_status',1)->get();
foreach($userBookings as $booking){
$events [] = [
'id' => $booking->id,
'calendarId' => $booking->id,
'title' => 'user name',
'category' => 'time',
'dueDateClass' => '',
'bgColor' => "#e6515f",
'color' => "#ffffff",
'isPending' => 'false',
'isFocused' =>'false',
'start' => $booking->start_datetime,
'end' => $booking->end_datetime,
];
}
return \Response::json([
'events' => $events ?? null
]);
}
