bega updates

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

View File

@@ -12,6 +12,21 @@ use Illuminate\Support\Facades\Http;
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 @@ if (! function_exists('translatable')) {
}
}
/**
* 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 @@ if (! function_exists('sendSMS')) {
}
}
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 @@ if (! function_exists('tmpostChannel')) {
/**
* Default channel
*
* @return App\Models\Shop\Channel
* @return \App\Models\Shop\Channel
*/
function tmpostChannel(): Channel
{
@@ -337,7 +375,7 @@ if (! function_exists('orderAdminNumber')) {
*/
function orderAdminNumber(): int
{
return 61126667;
return 65223722;
}
}