lundi 20 février 2017

Send email to report an error with user information in Handler.php

I send an email with bug information when laravel has an exception. But I would like to include the user information logged in at the time of the error.

In the Handler.php

public function report(Exception $exception)
{
    parent::report($exception);

    Mail::send('emails.errorreport', ['e' => $exception], function($message)
    {
        $message->to('email@email.com')->subject('Report error');
    });
}

In the emails/errorreport.blade.php

<h3>Error Information</h3>
<p><strong>Date:</strong> </p>
<p><strong>Message:</strong> </p>
<p><strong>Code:</strong> </p>
<p><strong>File:</strong> </p>
<p><strong>Line:</strong> </p>
<h3>Stack trace:</h3>
<pre></pre>

@if(Auth::user())
      <p><strong>   User: </strong> ID:  / Name:  / Email: </p>
@endif

It does not work. How to make?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2m1cXgy
via IFTTT

Aucun commentaire:

Enregistrer un commentaire