Level 70
@ddsameera I am wondering why you define everything belongsToMany()?
BTW, since it has many relationships, it will be hard to get any specific courses->meeting directly. You have to use a loop to get any specific records.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
User Model
public function courses()
{
return $this->belongsToMany(Course::class);
}
public function meetings()
{
return $this->belongsToMany(Meeting::class)->withPivot('unique_join_url');
}
Meeting Model
public function users()
{
return $this->belongsToMany(User::class)->withPivot('unique_join_url');
}
Course Model
public function users()
{
return $this->belongsToMany(User::class);
}
public function meeting(){
return $this->belongsTo(Meeting::class,'meeting_id','id');
}
I want to get Logged user's course meeting URL (Zoom Meeting URL)
Could you please help me ? to build up query in controller.
@tisuchi i created it by my self
$courseId = "1";
$course = Course::with('meeting')->get()->find($courseId);
$meetingUser = $course->meeting->users->first();
$uniqueJoinUrl = $meetingUser->pivot->unique_join_url;
Please or to participate in this conversation.