How to Passing Data to Views ?
Answer / 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 |
Explain the concept of contracts in laravel.
Is laravel a programming language?
How can we implement a package in laravel?
Tell me how to get current environment in laravel 5?
List some features of laravel 5.0?
Can you exclude uris from csrf protection in laravel? Explain
Explain me what is your favorite feature of laravel?
List the steps to configure laravel application.
What is guarded attribute in a model?
What is homestead in laravel?
How do I log an error?
How can you write your own service provider in laravel.