Level 1
I found that the solution as of Laravel 5.4+ is to use nested array as well in PHP:
$query->whereJsonContains('attributes', ['products' => ['media' => '1']]);
Or in older versions of Laravel:
$query->whereRaw(
'json_contains(attributes, ?)',
[
json_encode(['products' => ['media' => '1']])
]
);