think.studio/laravel-email-domain

1.1.0 2023-07-09 11:16 UTC

This package is auto-updated.

Last update: 2024-11-09 14:24:04 UTC


README

Packagist License Packagist Version Total Downloads Build Status Code Coverage Scrutinizer Code Quality

Installation

Install the package via composer:

composer require think.studio/laravel-email-domain

You can publish the config and assets files with:

php artisan vendor:publish --provider="EmailDomain\ServiceProvider" --tag="config"
php artisan vendor:publish --provider="EmailDomain\ServiceProvider" --tag="storage"

Usage

Example usage:

EmailDomainChecker::setDomainsFilePath('path/to.file')->isDomainInList('gmail.com');
EmailDomainChecker::usePublicProviderDomainsFile()->isDomainInList('gmail.com');

$email = 'test@gmail.com';
EmailDomainChecker::usePublicProviderDomainsFile()->isDomainInList(Str::afterLast($email, '@'));
EmailDomainChecker::usePublicProviderDomainsFile()->isEmailDomainInList($email);

// You can add your own groups in config `email-domain.domains_group_files` to check other groups

Trait usage:

class User extends Model
{
    use HasEmailDomainChecker;
}

$user->email = 'test@gmail.com';

$user->getEmailProviderDomain(); // gmail.com
$user->hasPublicEmailProviderDomain(); // true

Credits

  • Think Studio