We can keep views in the resources/views directory. In the laravel Html code are in the views files . It separate the controller/application logic from your presentation logic.
A view example is given below:
<!-- View stored in resources/views/greeting.php -->
<html>
<body>
<h1>Hello John, <?php echo $name; ?></h1>
</body>
</html>
This view is stored at
resources/views/green.php, we may return it using the global viewhelper function like so:Route::get('/', function () {
return view('green', ['name' => 'James']);
});
The above example shows that, the first argu. passed to the
view helper in respect of name of the view file in the resources/views directory. The second argu. passed to helper is an array of data that should be made available to the view. In the above example, we are just pass the name variable, which is displayed in the view by simply executing echo on the variable.
Of course, views may also be nested within sub-directories of the
resources/views directory. "Dot" notation may be used to reference nested views. For example, if your view is stored atresources/views/admin/profile.php, you may reference it like so:return view('admin.profile', $data);