Level 1
anyone could help me?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I create a website like Tinder, and I made the "matches managements" and the "blockage of user"... But, I can not join them.
The site have 3 tables : users (table of users), matches (table of crushs) ,blockages (table of users blocked)
In model User :
public function matchesOfMine(){
return $this->belongsToMany('App\Models\User', 'matches', 'user_id_from', 'user_id_to');
}
public function matchOf(){
return $this->belongsToMany('App\Models\User', 'matches', 'user_id_to', 'user_id_from');
}
public function matches(){
return $this->matchesOfMine()->wherePivot('accepted', true)->get()->merge($this->matchOf()->wherePivot('accepted', true)->get());
}
public function blockagesOfMine(){
return $this->belongsToMany('App\Models\User', 'blockages', 'user_id_from', 'user_id_to');
}
public function blockingOf(){
return $this->belongsToMany('App\Models\User', 'blockages', 'user_id_to', 'user_id_from');
}
public function blockages(){
return $this->blockagesOfMine()->get() ->merge($this->blockingOf()->get());
}
With theses codes, I can list all my crushes and all my users blocked. But, I would like to list all my crushes without users blocked... because if I blocked users, they should be in the matches...
Do you have an idea to do that? Thanks you in advance, Quentin
Please or to participate in this conversation.