In this Laravel project tutorial we will learn about Blade templates.
A view is what user will see on the screen when they visit the page.
In Laravel project the view files are placed inside the resources/views directory.
When we create a new Laravel project we get to see the following view when we visit the home page 127.0.0.1:8000.
The view file of this page is welcome.blade.php and it is inside the resources/views directory.
If we want to use Blade template in a view file then we have to save the file with .blade.php extension.
For our todo-laravel project we will first create a master layout that will be shared with all other pages.
It is a good practice to reuse your template code.
Inside the resources/views directory we will create a layouts directory and inside it we will create app.blade.php file.
We will now write the following code inside the app.blade.php file.
<!-- Required meta tags -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
In the above HTML code we have prepared a master layout for our project.
We are using Bootstrap 4 to style our website.
The @yield() directive is like a placeholder and we can fill it up with some content later when we use the master layout.
In the above code we have the @yield('title') which will help us to correctly set the title of the page.
And we have the @yield('content') which will hold the HTML of the current page being viewed by the user.
Alright, this is it for this tutorial. In the next section we will work on the Home page view.
And please share this tutorial if you find it helpful :)
See you in the next tutorial. Have fun coding.
Have fun learning :-)
Copyright © 2014 - 2019 DYclassroom. All rights reserved.
rendered in 0.0149 sec