This commit is contained in:
2025-10-22 20:08:22 +05:00
commit 736e3bef18
2573 changed files with 120385 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
namespace App\Modules\PhoneNumberVerification;
use App\Modules\Makeable;
use App\Modules\ModuleContract;
class PhoneNumberVerificationModule implements ModuleContract
{
use Makeable;
/**
* Module is enabled
*/
protected bool $enabled = true;
/**
* Check if is module enabled
*/
public function isEnabled(): bool
{
return $this->enabled;
}
/**
* Disable module
*/
public function disable(): void
{
$this->enabled = false;
}
/**
* Enable module
*/
public function enable(): void
{
$this->enabled = true;
}
/**
* Check if module has a filament resource
*/
public function hasFilamentResource(): bool
{
return false;
}
/**
* Get module composer requirements
*/
public function getComposerRequirements(): array
{
return [];
}
/**
* Get module composer suggestions
*/
public function getComposerSuggestions(): array
{
return [];
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Modules\PhoneNumberVerification\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class PhoneNumberVerificationRule implements ValidationRule
{
/**
* Run the validation rule.
*
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$value = preg_replace('/\D/', '', $value); // @phpstan-ignore-line
if (! is_numeric($value)) {
$fail('Telefon belgisi diňe sanlardan ybarat bolmaly.');
return;
}
$number = (int) $value;
$isValid = ($number >= 61000000 && $number <= 65999999) || ($number >= 71000000 && $number <= 71999999);
if (! $isValid) {
$fail('Telefon belgisi nädogry aralykda.');
}
}
}

View File

@@ -0,0 +1,14 @@
<?php
use Illuminate\Support\Str;
/**
* Unmask turkmen number
*/
function unMaskTurkmenNumber(string|int $number): string
{
return Str::of((string) $number)
->replaceMatches('/[^\d]/', '') // keep only digits
->whenStartsWith('993', fn ($str) => $str->after('993'))
->value();
}