prefix = $prefix ?? config('hashids.default_prefix'); } public function encodeId($id) { return $this->prefix.Hashids::encode($id); } public function decodeId($hash) { if (Str::startsWith($hash, $this->prefix)) { $result = Hashids::decode(Str::after($hash, $this->prefix)); if (count($result) > 0) { return $result[0]; // result is always an array due to quirk in Hashids libary } } throw new WrongIdException(); } }