Laravel:查询中间表

Suppose there are two tables with many to many relationship with each other.

users->id, name
skills->id, name
(intermediate table) skill_user->id, user_id, skill_id, custom

Now, i want to use this mysql query into eloquent form. What would be the eloquent form of below query?

select count(*) from skill_user where user_id=1 and skill_id=2 and custom="other"

I think this is what you want

select count( *) from skill_user where user_id=1 and skill_id=2 and custom="other"

$results = skill_user::where(['user_id'=>2,'skill_id'=>2,'custom'=>'other'])->get()->count();