Eloquent Puzzles 02: whereHas / AND / OR

Answer these 1 questions. There's no time limit.

Question #1 Question from Laracasts forum, let's try to solve it.

Imagine 2 models: Product and Attribute (BelongsToMany relationship)
See database data in the "Code snippet" section.

When filter products, user select RAM => [4GB, 8GB] and HDD => 256GB.

Goal is to get products that have (RAM - 4GB OR RAM - 8GB) AND (HDD - 256GB). In the database example, I should get products with ID 1 and 2 (Product 3 have RAM 4GB but doesn't have HDD 256, so doesn't count).

Please write Eloquent query for this, so something like:

$products = Product::whereHas [...some magic...] ->get();
Code snippet
Attributes table:

id      name
-------------
1       RAM
2       HDD

Products table:

id      name
-----------------
1       Product 1
2       Product 2
3       Product 3
4       Product 4

And the pivot table look like:

id      attribute_id            product_id     value
----------------------------------------------------
1       1 (RAM)                 1              8GB
2       2 (HDD)                 1              256GB
3       1 (RAM)                 2              8GB
4       2 (HDD)                 2              256GB
5       1 (RAM)                 3              4GB
6       2 (HDD)                 4              512GB
Please fill in your answer