In this video we are going to learn about the views.
View is a presentation layer that user can see.
It includes the HTML part, the styling part and all the front-end development.
View can be connected directly to the route or you can connect it with the controller also.
Alright now let's see how we can create a view.
For create a view just go inside the resources directory.
Then open views and here just create a new file.
Lets say file name is user.blade.php.
Now open this view file and here lets add html5 boilerplate.
So just type here ! sign and press tab.
Now change the title here.
Let's say title is User.
Now simply type some message in body part.
I am just going to type here.
User View inside the h1 tag.


<h1>User View</h1>


Now save it.
There are two way where we can render it.
With the controller and we can render it directly with the routings.
Lets render view through routing first.
So for that now switch to routes folder.
Click on web.php file.
and here just write a route for the user view.
So just write here.

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

Now save the file.
and go to the browser and just check.
so for that switch to browser.
and here just type localhost:8000/user.
Now you can see the user view.
Alright Now lets access the view using controller.
So for that create a controller.
Open command prompt and run the following command.


php artisan make:controller UserController


Alright now UserController has been created.
Now just open this UserController.
Here just create a method.

public function index()
{
return view('user');
}

Alright, now switch to web.php.
Here modify the route.


Route::get('/user',[UserController::class,'index'])->name('user.index');


Now check this.
So refresh the browser.
You can see its still working.
And now if you want to pass some data.
So for that just create a variable inside the index method and pass to the view.

public function index()
{
$name = 'jenifer';
return view('user',compact('name'));
}


Now go to the view file and inside this view file just put here h2 tag and display the name.

<h2>{{$name}}</h2>

Now save it and just check it on browser.
So switch to the browser.
and see the name you can also pass the array from the controller and render it on view.
For that create an array and pass to the view.


public function index()
{
$name = 'jenifer';
$users = array(
\"name\"=>\"James Watson\",
\"email\" => \"james@gmail.com\",
\"phone\"=>\"7765498789\"
);
return view('user',compact('name','users'));
}

Now we can access that users array inside the user view just write.

{{$users->name}}
{{$users->email}}
{{$users->phone}}

Now save the file.
And go to the browser and refresh.
Ok now you can see the result.
So in this way you can create view and pass any data from the controller to view in laravel 8.