lundi 28 août 2017

Laravel how to pass the name of the user when I sent the forgot password function

I want to make my mail more detailed when the user has sent a forgot password reset link to his/her email. This is the sample of the picture when receaving a reset password link.

enter image description here

I want to add some details here that the Hello should be Hello! (user name here)

Here is the code that I added in my SendsPasswordResetEmails.php

public function sendResetLinkEmail(Request $request)
    {
        $this->validateEmail($request);

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );

        $applicant_name = Applicant::where('email', $request->email)->get()->value('name');

        return $response == Password::RESET_LINK_SENT
                    ? $this->sendResetLinkResponse($response)
                    : $this->sendResetLinkFailedResponse($request, $response);
    }

and it should pass the data to my email.blade.php in my vendor/notifications/email.blade.php

@component('mail::message')

@if (! empty($greeting))
# 
@else
@if ($level == 'error')
# Whoops!
@else
# Hello! $applicat_name // Name of the applicant to be passed in after sending reset password request
@endif
@endif


@foreach ($introLines as $line)


@endforeach


@isset($actionText)
<?php
    switch ($level) {
        case 'success':
            $color = 'green';
            break;
        case 'error':
            $color = 'red';
            break;
        default:
            $color = 'blue';
    }
?>
@component('mail::button', ['url' => $actionUrl, 'color' => $color])

@endcomponent
@endisset


@foreach ($outroLines as $line)


@endforeach


@if (! empty($salutation))

@else
Regards,<br>CCTV Team
@endif


@isset($actionText)
@component('mail::subcopy')
If you’re having trouble clicking the "" button, copy and paste the URL below
into your web browser: []()
@endcomponent
@endisset
@endcomponent

I think I messed up with here. Would really appreciate if someone could help. Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire