bega updates

This commit is contained in:
Mekan1206 committed 2026-07-21 21:30:27 +05:00
1 parent 6093a45761
commit db94922e9a
22 files changed
+1033 -26

No files matched your search

+55 -17
View File
@@ -12,6 +12,21 @@
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
/**
* Translate
*/
function tr(string $text, string $locale = 'tk'): string
{
$text = json_decode($text);
if ($text) {
return $text->{$locale} ?? '';
}
return '';
}
if (! function_exists('modules_path')) {
/**
* Single translation for all locales
@@ -32,20 +47,6 @@ function translatable(string $text): array
}
}
/**
* Translate
*/
function tr(string $text, string $locale = 'tk'): string
{
$text = json_decode($text);
if ($text) {
return $text->{$locale} ?? '';
}
return '';
}
if (! function_exists('removeWhiteSpace')) {
/**
* Remove white sapce from string
@@ -105,22 +106,59 @@ function sendSMS(string|int $phone, string|int $message): mixed
}
}
if (! function_exists('normalizeTurkmenPhoneNumber')) {
/**
* Normalize a Turkmen phone number to the local 8-digit format.
*/
function normalizeTurkmenPhoneNumber(null|string|int $phone): null|string
{
if ($phone === null) {
return null;
}
$phone = preg_replace('/\D+/', '', (string) $phone);
if (str_starts_with($phone, '993') && strlen($phone) === 11) {
return substr($phone, 3);
}
return $phone;
}
}
if (! function_exists('isOtpBypass')) {
/**
* Fixed OTP bypass for the approved test phone number.
*/
function isOtpBypass(null|string|int $phone, null|string|int $code): bool
{
return normalizeTurkmenPhoneNumber($phone) === '65222548' && (string) $code === '12212';
}
}
if (! function_exists('sendSMSVerification')) {
/**
* Send a sms verification code
*
* @return App\Models\Verification | null
* @return \App\Models\Verification | null
*/
function sendSMSVerification(string|int $phone_number): ?Verification
{
$phone_number = normalizeTurkmenPhoneNumber($phone_number);
/* for apple testing */
$phone_code = ($phone_number == '61126667') ? 77777 : rand(10000, 99999);
$phone_code = ($phone_number == '65222548') ? 12212 : $phone_code;
$verification = Verification::where(['username' => $phone_number])->first();
$verification
? $verification->update(['code' => $phone_code])
: Verification::create(['username' => $phone_number, 'code' => $phone_code]);
if (isOtpBypass($phone_number, $phone_code)) {
return Verification::where(['username' => $phone_number])->first();
}
sendSMS($phone_number, 'Tassyklaýyş belgi: '.$phone_code);
return $verification;
@@ -181,7 +219,7 @@ function mask_phone(string|int|float $phone): string
/**
* Default channel
*
* @return App\Models\Shop\Channel
* @return \App\Models\Shop\Channel
*/
function tmpostChannel(): Channel
{
@@ -337,7 +375,7 @@ function validateCommaSeperated(?string $value, mixed $model = null): array
*/
function orderAdminNumber(): int
{
return 61126667;
return 65223722;
}
}