hey friends welcome back to BitFumes I'm your host Sarthak and you can also call me
Ankur this is the channel where we will talk about the Laravel cool things tips
and tricks and many things about the Laravel so if you are new to this channel
please don't forget to subscribe in this episode we are going to learn about the
MVC and how we can get started with the level actually there is a request from
our subscribers Sophie from Kenya she messaged me on Facebook and he asked a
question that I have already installed level and tested with the localhost and
it works perfect now how can I begin to code now ok so the question is actually
very basic how you can start in the level if you have learned how to install
the level or if you don't know how to install levels you can check out my
video on how to install level 5.4 by clicking this card ok so let me start it
so firstly I want to tell you what the MVC is so for that I have googled what
the MVC is at land on this Wikipedia page and in this page you can see you
can read actually this is system but don't worry I am NOT going to read this
so let's get on this picture so that picture is here so and this is just
stands for Model View and controller NPC so firstly talk about view what is view
ok so we had installed level here so you can see there is it h1 tag there is a
link also so all these things actually the HTML part is the view so let's get
the picture you can see the doctype HTML everything is HTML HTML and HTML so this
HTML part is our view obviously it is view that means it is viewable from the
user end ok so we understand view that means anything a user can see is a view
so where is this view is situated so we can go here
and when we go to our resources folder inside resources there is a view folder
so if you want to learn about what is blade dot PHP what is blade check out
this card so that you can learn about what the blade is ok so welcome here you
can see that all the HTML code are written here along with something in
curly braces also ok these are the things we have get from our controller
or we can say from our view wire controller and we put all these things
here in our view ok so we understand what is view okay anything that can be
viewable or seen by the user now it's time for the controller what is
controller it is a unit or it is a section of the model where you can
implement all the logic and you can get all the requests from the user and you
accept that request so let's see how we will use controller ok so where is the
controller situation situated for that you have to go to your app folder inside
that there is a HTTP folder and now there is a controller folder and you can
see there is a controller but this is not your controller so you have to make
a controller how can we make a controller for making controller we will
go to our command prompt we will type PHP artisan make controller and the
controller name is boomkin controller controller ok controller is created if
you don't so what do you think what I am doing what I am typing here so don't
worry just see what I am going to explain you you will get all these
things in the videos of this series ok you can watch all the videos and after
that if you have any doubts please comment me ok so just what and don't
worry about all these things so you can see
our home controller is there and now what we will do in controller in
controller we make a function and we name that function okay
this function is indexed so here I will just say return return what view and
view name is let's say welcome and as we have made controller so I have told you
controller is just for your logic so what the logic is real
actually there is no logic we just say return of view that means if you call
this index function then it will return of you so how does index function be
called for that you have to go to web dot PHP or where is that web dot PHP web
dot paste is inside your out folder and even see web dot PHP here you can see
that it is says that route that means if there is a get request you know I think
what is get requested when there is a get request and there is homepage that
means your base URL is called then you will return a view instead of this what
I am going to do I am going to say route and when there is a get request for the
base URL you have to go to home controller and in the home controller
which function you have to pass you have to call that index function okay so when
there is a get request on your base URL then it will call home controller and
inside home controller it will call index function okay so when I go to my
local work I will hit refresh and you can see there is no error because we are
actually returning the view from our controller so you can see we have just
clean our web dot PHP page okay now what about the logic let's say if you have a
variable called sum and in that some you have typed 5 plus 6 okay let's see let's
return this and see what the well dis now comment this click refresh
and you can see 11 and we know all these maps again so now what I am going to do
is I am going to just get this variable on my view and where is that you use
inside resource and welcomed or delayed dot PHP I want to echo I want to show
this some variable and the value of that some variable inside my view select see
how we will do we will just say compact and here I will type some what this
means this means that I have passed this
variable oh we don't have to say dollar you have to just table name okay what
this statement means this is statement field that you have passed this some
variables in your view okay now this sum variable is accessible in youth you also
so let's see how we can do we can go to our view after this level I will just
echo the sum okay okay this sum variable is came from
this controller okay now click refresh and you can see xi is now what actually
we have done we have created a logic and the result of that logic is passed to
the welcome dot plate dot PHP that means inside our view so as we as I have told
you view are simply for the viewer and you are interact and interact with your
website with your project and that interaction that the data you will
process inside the controller and return back to that view okay so it's very much
easy now comes for the model what the model do model is just like your brain
model is actually storing data inside the database obviously so how we can
make model similarly we have to write a command and obviously it will say make
model model name is let say one so here you can see now the home model is
created inside our app folder after this you can use that model here you can say
home and now when now you can get data from from your home model by saying
various commands okay in this way you can get the data from the database you
have got the idea what the MVC is and the further you wash my videos you will
get more and more deeper knowledge how the things work okay so let's recap wall
what we have done in this episode in this episode we have learned about the
view that means the user interaction that means the HTML part okay after that
we have learned about controller what the controller is controller is just a
place where you will put all your logic and return the result of that logic a
deal to the view okay and next is the model and the last we have learned about
the model model is just like your brain it will get the data from the controller
okay and it will store that data to the database and again if you want that data
that data model if that data to controller to make and logic and
obviously after that logic the controller's return that data to view so
actually this episode is just for the business who doesn't know anything about
lateral anything about any system so if you have learnt from this episode please
give it a thumbs up like this video and share this video with your friend who
just want to implement just one to get over the lateral over the ambitious
Timms so if you have any doubt in this episode all in any on project then
please comment me on the comment section you can follow me on Twitter Facebook
and Instagram okay so we will meet in the next episode where we will learn
something new something more interesting something cool about the level till then
just keep coding and don't forward subscribe bye bye