Closed timgavin closed 5 years ago
Using Laravel 5.8 and PHP 7.3.3
Encoding works fine, but decoding produces an empty array []
[]
public static function encodeHashId($id) { $hashids = new Hashids('', 8, 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNOPQRSTUVWXYZ'); return $hashids->encode($id); } public static function decodeHashId($id) { $hashids = new Hashids(); return $hashids->decode($id); } $id = 'ZGkbkrdn'; $id = static::decodeHashId($id); dd($id); // produces [] instead of 1
This is normal, you do not use the same instanciation. Use the same instanciation and it will works. Next, to avoid this kind of error, use dependency injection.
Using Laravel 5.8 and PHP 7.3.3
Encoding works fine, but decoding produces an empty array
[]