Files
preregister/app/Providers/AppServiceProvider.php
bert.hausmans 17e784fee7 feat: E.164 phone validation and storage with libphonenumber
- Add giggsey/libphonenumber-for-php, PhoneNumberNormalizer, ValidPhoneNumber rule

- Store subscribers as E.164; mutator normalizes on save; optional phone required from form block

- Migration to normalize legacy subscriber phones; Mailwizz/search/UI/tests updated

- Add run-deploy-from-local.sh and PREREGISTER_DEFAULT_PHONE_REGION in .env.example

Made-with: Cursor
2026-04-04 14:25:52 +02:00

42 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Providers;
use App\Models\PreregistrationPage;
use App\Services\PhoneNumberNormalizer;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
$this->app->singleton(PhoneNumberNormalizer::class, function (): PhoneNumberNormalizer {
return new PhoneNumberNormalizer(
(string) config('preregister.default_phone_region', 'NL')
);
});
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Paginator::useTailwind();
Route::bind('publicPage', function (string $value): PreregistrationPage {
return PreregistrationPage::query()
->where('slug', $value)
->where('is_active', true)
->firstOrFail();
});
}
}