I don't know if the typo is in your actual code, but I'm pretty sure that it should be $secret_key = $document->snapshot->get('secret_key');, not $document->snaphot.
$secret_key = $document->snapshot->get('secret_key');
$document->snaphot