Skip to content

Commit

Permalink
Merge pull request #8 from TheoKouzelis/fix/trans-laravel-6
Browse files Browse the repository at this point in the history
Add support for laravel 6
  • Loading branch information
TheoKouzelis authored Sep 25, 2019
2 parents b8907f1 + 7e340f5 commit 0f2ba77
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class ServiceProvider extends BaseServiceProvider
{
protected $transKey = 'mailgun-email-validation::validation.mailgun_email';

public function boot()
{
$this->publishes([
Expand All @@ -16,7 +18,7 @@ public function boot()

$this->loadTranslationsFrom(__DIR__ . '/../lang/', 'mailgun-email-validation');

$message = $this->app->translator->trans('mailgun-email-validation::validation.mailgun_email');
$message = $this->getMessage();

Validator::extend('mailgun_email', 'Kouz\LaravelMailgunValidation\EmailRule@validate', $message);
}
Expand All @@ -27,4 +29,13 @@ public function register()
return new EmailRule(new Client(), $app['log'], config('mailgun-email-validation.key'));
});
}

protected function getMessage()
{
if (method_exists($this->app->translator, 'trans')) {
return $this->app->translator->trans($this->transKey);
}

return $this->app->translator->get($this->transKey);
}
}

0 comments on commit 0f2ba77

Please sign in to comment.