我正在开发一个laravel商店,包括密码重置功能。到目前为止一切都很好,一切都很好,同时我还实现了一个“电子邮件刀片文件”来自定义邮件文本的内容。
@component('mail::message')
{{-- Greeting --}}
@if (! empty($greeting))
# {{ $greeting }}
@else
@if ($level === 'error')
# @lang('Es tut uns leid!')
@else
# @lang('Guten Tag!')
@endif
@endif
{{-- Intro Lines --}}
@foreach ($introLines as $line)
{{ $line }}
@endforeach
{{-- Action Button --}}
@isset($actionText)
<?php
switch ($level) {
case 'success':
case 'error':
$color = $level;
break;
default:
$color = 'primary';
}
?>
@component('mail::button', ['url' => $actionUrl, 'color' => $color])
{{ $actionText }}
@endcomponent
@endisset
{{-- Outro Lines --}}
@foreach ($outroLines as $line)
{{ $line }}
@endforeach
<!--
{{-- Salutation --}}
@if (! empty($salutation))
{{ $salutation }}
@else
@lang('Regards'),<br>
{{ config('app.name') }}
@endif
{{-- Subcopy --}}
@isset($actionText)
@slot('subcopy')
@lang(
"If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\n".
'into your web browser:',
[
'actionText' => $actionText,
]
) <span class="break-all">[{{ $displayableActionUrl }}]({{ $actionUrl }})</span>
@endslot
@endisset
-->
@endcomponent
正如你所看到的,一些东西被注解掉了,因为我并不使用所有这些东西。在这里我可以处理一些像问候,问候等等。除此之外,我还实现了一个新的notofication:重设密码:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class ResetPassword extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Shucube - Passwort vergessen?')
->line('Sie haben Ihr Passwort vergessen? Kein Problem...')
->action('Passwort Link', url('/'))
->line('Beste Grüße...');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
这也很好用。主要部分你可以在toMail()函数中看到。总而言之,你可以说我在ResetPassword.php中处理主要内容,在Blade文件中处理一般部分。很酷的东西。
但是直到现在我还不能删除邮件顶部的laravel标志。在最好的情况下,我想用我自己的标志来代替它。有人有主意吗?
email
2条答案
按热度按时间5jvtdoz21#
从shell运行
php artisan vendor:publish
,然后选择Laravel-mail。这将在resources/views/vendor/mail中为邮件创建刀片视图ylamdve62#
如果您将.env文件中的APP_NAME从“Laravel”更改为其他任何内容,它将消失