我有这个代码:
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use App\Mail\ContatoRecebido;
use App\Mail\ContatoRespondido;
class ContatoController extends Controller
{
//
protected $mailto = 'email@gmail.com';
public function showForm()
{
return view('emails.contato');
}
public function sendForm(Request $request)
{
$request->validate([
'nome' => 'required',
'email' => 'required|email',
'mensagem' => 'required',
]);
$recebido = new ContatoRecebido ($request);
$respondido = new ContatoRespondido($request);
Mail::to($this->mailto)->send( $recebido);
// Envia o e-mail de resposta para o remetente
Mail::to($request->email)->send($respondido);
return redirect('contato')->with('success', 'Mensagem enviada com sucesso!');
}
以及
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Mail\Markdown;
use illuminate\Mail;
class ContatoRespondido extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public $dados;
public function __construct($dados)
{
$this->dados = $dados;
}
public function build()
{
$array = [
'nome' => $this->dados->nome,
'email' => $this->dados->email,
];
# dd ( $array );
# return $this->markdown->render('emails.envia')->with($array);
#return $this->markdown('emails.envia', $array);
return $this->markdown('emails.enviaestatico');
}
}
但是,当我试图逃跑的时候,我收到了:参数无效异常未找到视图[]。(视图:/主页/hotckless/www/institutoami/resources/views/emails/enviaestatico. blade. php)
但是视图('enviaestatico'(. blade.php)存在于视图/电子邮件/文件夹中。
我都快疯了。
我尝试将目标更改为静态文件,尝试将Markdown更改为View:return $this-〉view('...'),并尝试创建www.example.com文件的路径view.app,并创建了'mail' =〉resource_path('views/emails'),但没有任何React!
1条答案
按热度按时间2admgd591#
使用
$this->view
代替$this->markdown