Match All From Array In Laravel 5 Pivot

I’m trying to figure out the best approach returning IDs where another model’s IDs match exactly all in Laravel 5 Eloquent

//the array to match
$array = [1,7,8];

Pivot Structure

id, model_a_id, model_b_id

return all model_a where model_b_id match exactly the number of elements and in $array. If it has more or less elements then don’t return anything or false.

Does anyone know how I can do this?

Thanks!


Source: stackoverflow-php