File: //proc/thread-self/cwd/app/Providers/AppServiceProvider.php
<?php
namespace App\Providers;
use App\Services\ApiEndpoints;
use App\Services\DeviceService;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
$this->app->singleton(DeviceService::class, function ($app) {
return new DeviceService();
});
$this->app->singleton(ApiEndpoints::class, function ($app) {
return new ApiEndpoints();
});
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Validator::extend('valid_password', function ($attribute, $value, $parameters, $validator) {
if (strlen($value) < 8) {
return false;
}
if (!preg_match('/[A-Z]/', $value)) {
return false;
}
if (!preg_match('/[0-9]/', $value)) {
return false;
}
return true;
}, 'Password must be at least 8 characters long, contain at least 1 uppercase letter, and 1 number.');
Validator::extend('valid_email_domain', function ($attribute, $value, $parameters, $validator) {
$allowedDomains = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com', '@ymail.com'];
$domain = substr(strrchr($value, "@"), 1);
return in_array($domain, $allowedDomains);
}, 'The :attribute is not verifiable, please try again with different email address.');
}
}