What is different here from this thread?
https://laracasts.com/discuss/channels/laravel/what-is-the-correct-way-to-use-relation-in-query
Nothing.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
A User can join any number of INNER CIRCLES ( something like groups ). Now whenever a User list a property , I need to send emails to all the members of all the circles he has joined. What will be the query ?
Model User
public function circlemember()
{
return $this->hasMany(InnerCircleMember::class, 'member_id', 'id');
}
Model InnerCirclemember
public function member(){
return $this->belongsTo(User::class,'member_id');
}
public function circle(){
return $this->belongsTo(InnerCircle::class,'circle_id');
}
Model InnerCircle
public function circlemember()
{
return $this->hasMany(InnerCircleMember::class, 'circle_id', 'id');
}
Controller:
$allusers = User::where('status' , 1)
->whereRoleIs('broker')
->where('email_verified_at', '<>', NULL)
->where('mailforcircles', 1)
->get();
What will be the correct query ? Presently I have no idea from where I should start ? :)
Please or to participate in this conversation.