I have 2 tables, users and skills, and a many to many relationship between them. Pivot table skill_user also has column 'level' - at what level this user knows this skill.
in User model I have:
public function skills(){
return $this->belongsToMany('Skill')->withPivot('level');
}
and in Skill model:
public function users(){
return $this->belongsToMany('User');
}
Now, I need to run a query which will return something like this:
"Select all users who has skill_id_1 > 40 && skill_id_2 > 55 && skill_id_3 > 67"
where skill_ids are different skills, and each user returned should have each of the given skill at required level.
I searched in Laravel documentation and in stackoverflow as much as I could but couldn't find the solution. Any help will be appreciated, thanks!