1
我有一个网站,加密和解密输入到文本框中的数据,当我点击“加密”应用程序将发送包含加密的电子邮件信息。Laravel 5.4:当通过电子邮件发送变量变为NULL
问题:电子邮件包含一切,除了实际的加密消息。
我使用mailtrap查看发送的电子邮件。 这里的代码:
控制器:
public function encrypt(Request $request){
$output = encrypt($request->name);
Mail::to('[email protected]')->send(new EncryptionSent($output));
return view('decrypt', ['output' => $output,]);
}
的Mailables:
class EncryptionSent extends Mailable{
use Queueable, SerializesModels;
public $output;
public function __construct($output){
//
}
public function build(){
return $this->from('[email protected]')->view('decrypt', ['output' => $this->output]);
}
}
观:
@extends ('home')
@section('content')
<div style = "width: 250px;border: 1px solid #000000;word-wrap:break-word">
<!-- The Decrypted code is located here -->
{{ $output }}
</div>
<form action="{{ url('/decrypt/'.$output)}}" method="POST" class="form- horizontal">
{{ csrf_field() }}
<br/><br/>
<button type="submit" class="btn btn-default">
<i class="fa fa-btn fa-plus"></i> Decrypt!
</button>
</form>
@endsection
我用DD()来找出问题所在,但是$输出总是返回控制器中的加密消息并且可以邮寄。
感谢您的阅读,希望有人能帮助!
不要使用** **全球。使用$ output作为参数或作为对象的属性(** $ this-> output **) –
感谢您的提示,我更改了代码;结果仍然是一样的。 –
嘿:)你忘了在__construct方法中设置属性: '$ this-> output = $ output' –