【问题标题】:How to pass additional information into Laravel Jetstream team invite email如何将其他信息传递给 Laravel Jetstream 团队邀请电子邮件
【发布时间】:2023-03-23 19:15:02
【问题描述】:

如果用户已经在我的应用中拥有帐户,我想捕获。直到收到团队邀请电子邮件为止,我的所有工作都正常进行,我无法传递价值。如果我dd($invitation) 我可以看到我的价值在那里,但如果我使用$invitation->existing_user 它不会显示。这是我的代码:

@component('mail::message')
{{ __('You have been invited to join the :team team!', ['team' => $invitation->team->name]) }}
{{ __('Existing User:') }} {{$invitation->existing_user}}

@if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::registration()))
{{ __('If you do not have an account, you may create one by clicking the button below. After creating an account, you may click the invitation acceptance button in this email to accept the team invitation:') }}

@component('mail::button', ['url' => route('register')])
{{ __('Create Account') }}
@endcomponent

{{ __('If you already have an account, you may accept this invitation by clicking the button below:') }}

@else
{{ __('You may accept this invitation by clicking the button below:') }}
@endif


@component('mail::button', ['url' => $acceptUrl])
{{ __('Accept Invitation') }}
@endcomponent

{{ __('If you did not expect to receive an invitation to this team, you may discard this email.') }}
@endcomponent

你可以在第二行看到我添加的内容,其他都是原始代码。

【问题讨论】:

    标签: php laravel laravel-8 jetstream


    【解决方案1】:

    从你的控制器发送这样的数据

    $data = [
       'team_name' => $invitation->team->name
    ];
    

    然后在视图中,你可以得到如下数据。

    @component('mail::message')
    
       {{ __('You have been invited to join the :team team!', ['team' => $data['team_name']]) }}
    
    @endcomponent
    
    

    【讨论】:

    • 感谢您的回复。问题在于控制器位于 Jetstream 供应商文件中,因此最终会被更新覆盖。
    • @AndrewFox 我刚刚想通了。你 dd($invitation) 在这个电子邮件模板中,对吗?如果您可以看到值,请尝试访问 $invitation['existing_user'] 而不是使用箭头符号。
    猜你喜欢
    • 2022-01-04
    • 2020-05-18
    • 2018-09-26
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多