Answer Posted / rachana devi
While building application it may be required to pass data to the views.
Pass an array to view helper function.
After passing an array, we can use the key to get the value of that key in the HTML file.
Example :
Observe the following example to understand more about passing data to views -
Copy the following code and save it at resources/views/test.php
<html>
<body>
<h1><?php echo $name; ?></h1>
</body>
</html>
Add the following line in app/Http/routes.php file to set the route for the above view.
app/Http/routes.php
Route::get('/test', function(){
return view('test',[‘name’=>’Virat Gandhi’]);
});
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to get last inserted id using laravel query?
What is service provider in laravel?
Is laravel good for ecommerce?
are you able to laravel create-project via composer, explain how?
What is a Laravel - Encryption ?
What is auth in laravel?
Why are migrations important?
What are traits in laravel?
Do you know what is luman?
How do I make a middleware to be run during every http request to an application?
What is valet used in laravel 5?
How to pass csrf token with ajax request?
What does valet park?
What is dd () in laravel?
What is composer lock in laravel?