In this video we are going to learn about blade templates.
Blade is the in built templating engine for Laravel framework.
Blade is a very powerful and easy to use templating engine that makes writing syntax very easy and readable.
Blade templating engine comes with its own control structure such as conditional statements and loops.
Blade templates are typically stored in the views directory inside the resource folder.
Now lets create blade template file.
So goto the project and click on resource folder.
And now right click on views and create a new file.
Let say blade name is test so just type here.
A blade template file is now created here.
Inside this blade file.
I am going to type here a message.
Like inside the h1 tag.

<h1>test blade</h1>

Alright now for access this blade view.
Lets create a route.
So goto the web.php.
For that click on routes then open web.php.
Inside this file lets create a route.

Route::get('/test', function (){
return view('test');

Now save the file and check it.
So switch to the browser and here type /test.
Ok, you can see this message,
This text is coming from the test blade file.
Now, lets see how can we create a variable inside the blade template file.
So go to the test blade and here lets create a variable.
For php code in blade template We use @php directives.
So just type @php and @endphp Inside the @php directives define a variable.
Let say variable name is $name and value \"Jenifer\".


Now print this name variable value Using double curly bracket {{}}.

Hello {{$name}}!

Now save the file and see on browser.
You can see here hello jenifer.
Lets create an array here.
So type inside the @php directives just write.

$fruits = array('mango','apple','orange');

Now lets see the if statements.
Now use this array inside the if statements.

Single Fruit.
More than one fruits.
No Fruit.

Lets check it on the browser.
Refresh the page.
You can see more than one fruit.
If I change the array and remove these two and now check.
You can see single fruit.
Now lets remove all the element from here.
Now you can see no fruit.
Now lets see the loop in blade template lets see @for directives first.
So here type.


Save the file and see the result.
You can see here 1 to 10 numbers.
Now lets see @foreach directives For understanding @foreach directives.
just add some element inside the array.
So type here \"mango\",\"orange\",\"apple\".
Now display each elements from the array using @foreach directives.

@foreach($fruits as $fruit)

Save the file and check the result.
You see here all the fruits.
Now lets see ternary operator.
For understanding ternary operator.
Just Create a variable here.


Now Lets use this variable inside the ternary operator.

{{$age >=18 ?'you are an adult':'you are not an adult';}}

If this condition is true then this true part will be returned.
and if condition is false then this false part will be returned.
Alright now check.
So just refresh the page you can see here this message.
and if I change the $age with 12.
Now check, you can see here.
You are not an adult.
Blade template engine provides @include directive for including a view inside another view.
The child view will have all the variables that are available to parent view. Ok.
For understanding @include directive just add another view.
So go to the view folder and create new blade file.
Lets say headers.blade.php.
Now put some text here.

<h1>Blade Templates</h1>

Now add this view to the test blade so.
Just type here.


Now lets check.
You can see the headers blade content is now showing here.
So in this way you can use blade template in laravel 8.