Files
monica/app/Notifications/ConfirmEmail.php
T
dependabot-preview[bot] 387e45b85d chore(deps): bump laravel/cashier from 8.0.1 to 9.3.5 (#2857)
* chore(deps): bump laravel/cashier from 8.0.1 to 9.3.5

Bumps [laravel/cashier](https://github.com/laravel/cashier) from 8.0.1 to 9.3.5.
- [Release notes](https://github.com/laravel/cashier/releases)
- [Changelog](https://github.com/laravel/cashier/blob/9.0/CHANGELOG.md)
- [Upgrade guide](https://github.com/laravel/cashier/blob/9.0/UPGRADE.md)
- [Commits](https://github.com/laravel/cashier/compare/v8.0.1...v9.3.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-10 16:12:47 +02:00

81 lines
2.0 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\User\User;
use Illuminate\Bus\Queueable;
use App\Models\Account\Account;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\URL;
use App\Interfaces\MailNotification;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification as LaravelNotification;
class ConfirmEmail extends LaravelNotification implements ShouldQueue, MailNotification
{
use Dispatchable, InteractsWithQueue, Queueable;
/**
* @var bool
*/
public $force;
public function __construct($force = false)
{
$this->force = $force;
}
/**
* Get the notification's delivery channels.
*
* @return array
*/
public function via()
{
if (! $this->force) {
$first = Account::count() == 1;
if (! config('monica.signup_double_optin') || $first) {
return [];
}
}
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param User $user
* @return MailMessage
*/
public function toMail(User $user) : MailMessage
{
App::setLocale($user->locale);
return (new MailMessage)
->subject(trans('mail.confirmation_email_title'))
->line(trans('mail.confirmation_email_title'))
->line(trans('mail.confirmation_email_intro'))
->action(
trans('mail.confirmation_email_button'),
$this->verificationUrl($user)
);
}
/**
* Get the verification URL for the given notifiable.
*
* @param mixed $notifiable
* @return string
*/
protected function verificationUrl($notifiable)
{
return URL::temporarySignedRoute(
'verification.verify', now()->addMinutes(60), ['id' => $notifiable->getKey()]
);
}
}