lundi 30 octobre 2017

How do I pass data from my controller to a view in Laravel 5.5?

I have a function that I'm trying to pass some data to a view. I can't get the Route to recognize the data, it just keeps saying my variables are undefined. Here's what I'm trying to do:

return redirect('confirm')->with([
   'name'=>$name,
   'service'=>$service,
   '$email_address'=>$email_address
]);

Then in my web.php file, I have:

Route::get ('confirm', function($name,$service,$email_address){

return view('confirm',compact('name','service','email_address'));
})->name('confirm');

Laravel just throws an error "Missing argument 1 for Illuminate\Routing\Router::{closure}()"

I'm at a complete loss, I've tried this a bunch of different ways. If I call the view right from my controller, it works fine, but then URL isn't what I want it to be, so it seems like I have to return the redirect and reference the data in my route definition. Can anyone enlighten me?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire