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
What is a Terminable Middleware ?
How to set database connection in laravel?
Tell me in which language it was written?
How do I set up the eloquent relationships between the aforementioned comments and authors, including creating the schema design?
What is redirect routes?
Is laravel an mvc framework?
How do I require authentication for a set of routes associated with a subdomain?
What are accessors and mutators in eloquent and why should you use them?
What is method spoofing?
Explain how to generate pretty urls in laravel?
Explain short notes on Laravel - Artisan Console and commands ?
How to Sharing Data with all Views ?
How to rollback last migration?
List out common artisan commands used in laravel.
Is laravel safe from sql injection?