I am creating web site. In this web site, I have created a Registration Form. User can Input details and when user clicks Submit button all the data save into the database. Here is my saveInvoice function. In my view page I have used saveInvoice as my action. Then I used request inputs in this function.
public function saveInvoice(Request $request)
{
if (Auth::user())
{
$settings = Setting::find(1);
$invoiceNo=$settings->invoiceprefix.''.str_pad($settings->invoiceno, $settings->invoicepadding, 0, STR_PAD_LEFT);
$invoice= new Invoice();
$invoice->invoicereference=$invoiceNo;
$invoice->firstname=$request->fname;
$invoice->lastname=$request->lname;
$invoice->save();
$settings->invoiceno=$settings->invoiceno+1;
$settings->update();
if($invoice == null){
return redirect()->back()->with('msg','invalid request');
}
else{
return redirect()->route('invoice.preview',$invoiceNo);
}
}
}
But , Now I want to create another function called sendemail. In this function I want to use user inputs which user has filled in that registration form. Can I get those request inputs from this above function or is there a another method ??
public function sendemail(Request $request) {
$invoiceNo = $request->input('invoiceNo');
$fname = $request->input('fname');
$Qty = $request->input('Qty');
$price = $request->input('price');
$sendemail = $request->input('email');
$data = [];
$data['invoiceNo'] = $invoiceNo;
$data['fname'] = $fname;
$data['Qty'] = $Qty;
$data['price'] = $price;
$data['sendemail'] = $sendemail;
Mail::send(['text' => 'mail'], $data, function ($message) use ($data) {
$message->to($data["sendemail"], 'TicketBooker')->subject
('CheapEfares Air Ticket');
$message->from('[email protected]', 'CheapEfares');
});
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…