|
@@ -6,6 +6,27 @@ use Illuminate\Support\Str;
|
|
|
use Jenssegers\Agent\Agent as Agent;
|
|
|
use Unirest\Request;
|
|
|
|
|
|
+function getHashSorderNo($sorderNo)
|
|
|
+{
|
|
|
+ $sorderNoExplode = explode('-', $sorderNo);
|
|
|
+ return $sorderNoExplode[0] . '-' . generate4DigitHash($sorderNo);
|
|
|
+}
|
|
|
+
|
|
|
+function generate4DigitHash($input)
|
|
|
+{
|
|
|
+ // Generate a SHA-256 hash
|
|
|
+ $hash = hash('sha256', $input);
|
|
|
+
|
|
|
+ // Convert hash to base 10 and get the first 4 digits
|
|
|
+ $decimalHash = base_convert($hash, 16, 10);
|
|
|
+
|
|
|
+ // Truncate or pad to ensure it's 4 digits long
|
|
|
+ $fourDigitHash = substr($decimalHash, 0, 4);
|
|
|
+
|
|
|
+ // Ensure it's always 4 digits
|
|
|
+ return str_pad($fourDigitHash, 4, '0', STR_PAD_LEFT);
|
|
|
+}
|
|
|
+
|
|
|
function detect($view)
|
|
|
{
|
|
|
$agent = new Agent();
|