Passing data to view

Passing data to view

Data can easily be passed from route to view by passing second argument to view and this argument is an array that is key value pair or we declare array in a variable and use this variable as a second argument. Here each key is a variable

For Example

Route::get (‘/contact’, function () {

    return view (‘contact’, [‘name’ => ‘shairy’, ‘contact’ => 8054583502]);

});

This Key can be easily access in the view by php variable as a blade temple using double curly braces like this. This allow us to output a dynamic value of or a variable that we pass

  {{$name}}

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*