I am working on building a form in which I want to populate the fields coming from form (which I have named posting.blade.php
)
The controller which I have used for that is:
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required|email',
'number' => 'required',
'city' => 'required',
'post' => 'required'
]);
Mail::send('emails.posting-message', [
'msg'=> $request->message
], function($mail) use($request) {
$mail->from($request->email, $request->name);
$mail->to('[email protected]')->subject('Contact Message');
});
return redirect()->back()->with('flash_message', 'Thank you for your message');
}
Problem Statement:
The current controller doesn't return anything as in the line 'msg'=> $request->message
there is no message in validate. But if I use
'msg'=> $request->name
(It returns name)
I am wondering what changes I should make in the controller so that it return every field present in the validate.
I tried with this but its only returning the last value which is post.
'msg'=> $request->name,
'msg'=> $request->email,
'msg'=> $request->number,
'msg'=> $request->city,
'msg'=> $request->post
old()
function by the middle of it. Invest time on it mate. It is totally worth it. – Wotton