hey what's going on guys welcome back to this blog and this is the third part of our laravel tutorial series and in this blog we're going to talk all about the basic routing and controllers but before we do that let's just run through the code or structure of our project right now so as we have mentioned before laravel uses the Model View controller or MVC format or structure so here in our project there's specific areas for those types of things so there's specific areas for the modal there is a specific area for the view and specific area for our controllers so we're going to get to that later on on this blog and if we try to open the app folder here we can see the user that PHP file which is this is actually a modal and we won't go through the code right now but this particular file is a user or I mean a model user that PHP and we can add all the models here inside the app folder but we can actually use or we can actually have a another folder here so you can add project folder here and try to name it as models if we have if we have like 50 or 100 models for our project so we can add a subfolder for this app folder but if you have only maybe less than 10 or less than 20 models you can just leave it here inside the app folder and also if you try to open up the folder and under HTTP and then controllers here we can see the base controller that PHP which is extending the base controller and all the methods and functions of this base controller we can use it in our controller files and also learn creates a folder for the other controllers such as the lagging controller register controller and reset password controller so all of these controllers we can use we can use this readily if we try to enable the oath for our project and if we try to create a controller we can actually manually create a file here or that PHP file which is for our controller and also we can use or we can create a model by just manually adding it here but the best way for adding controllers and and the model is by using the artisan now if you're wondering what is this namespace name space app so this is just basically grouping our classes or our cold so this is a pretty common if especially if you're working the object-oriented way of programming so we're just basically grouping or our classes and try to distinguish between different classes and the same classes inside this directory and also if you see the illuminate here don't get confused it is just basically a core files or core functions coming from the laravel so don't worry about this now views are gonna be on the resources folder and under resources juice and then here we have the Welcome that laid that PHP and as we all know that laravel uses the blade template in system so it is just basically a HTML with dynamic mechanism in them so we can see if statement we can see loops we can see variables by using the rating system okay so now that we get that out of the way we can go to basic routing for our project so basically we're what we want is to add a pages controller where we can add we about pages home pages contact or any other page that we want to add in our project so if you try to go to our project and routes here and when you can see we can see here that we have gear out and Colin Colin and then the type of request that we want and then the URL and of course the function that return something or put a lot of operation inside this function so try that for now and let's try to open up our project in a browser so here is our project and PK project that LOC slash so here's the home page where we can see all the links and the title laravel now let's try and go back to our code and try to edit and instead of our returning the Welcome we can just return something like attacks or string so return HelloWorld something like this and then save and let's go back to our browser and refresh so as you can see we have here the hello world tax that we can see and it is coming from our router or route and get and then the URL which is the slashes represent the home page of our project and of course the string hello world okay so for now let's copy this and let's just return this to the original or our index so this is the homepage of our app or application and this will be the hello page of our project so this is basically we're just going to display hello world and we can just we can also add HTML tag in here so just like that and then save and let's go back to our browser and in refresh so P key project that LOC this will be the home page right and we try to add hello here it will display our update and hello world string and this is where dh1 tab now if you are trying to submit the form or you are going to delete something so you can just change this into post if you are submitting via form so working with the route is very easy so say for example we have pages in our project and let's try to go to where is it resources and then we want to separate our pages here so let's just add a pages folder and in this folder we're going to create another file which is the name of our file will be the about about laid that PHP okay so in order about that lay that page people can just say about okay save that one and let's go back to our route file and instead of I think we're just going to change this and to get then let's just stop B and paste this here so instead of hello so we're just going to name it about or the URL will be slash about in the set of returning the HTML so we're going to return the view now and notice that we have the the about view inside our pages folder so we're just going to add pages and then add that or period they're there and then the keyword about so let's try it save the file and let's go back there about okay so here we are at our browser and instead of using the low let's change it into a brown so as you can see here we have the about word here that is coming from our about that late that page be fine and also there are times that we need to submit dynamic values in our request so say for example we want to submit or we want to request user with this particular ID so let's go back to our web page B file and let's just copy this so instead of just using the about let's change it I think for a change the two users and then in order for us to be able to submit an ID so we can just add a placeholder here and this will represent our ID and inside our function it should have a parameter ID that represents the idea of the user so instead of returning the view for now let's just display this is a user and then we're just going to add the name or the ID of the user so let's just save this and go back to our browser and refresh so instead of using the about so let's go ahead and try to open up the users and let's try to submit esteem so this is a user 15 or suffer sample name name of the user as Jo this is a user is Jo but most of most of the time warriors we are requesting a particular ID and then based on that ID we can clearly that into our database all right guys I think that's it for this particular blog and in the next blog we're going to discuss how to create controllers inside our laravel project thanks
hey what's going on guys welcome back to this blog and this is the third part of our laravel tutorial series and in this blog we're going to talk all about the basic routing and controllers but before we do that let's just run through the code or structure of our project right now so as we have mentioned before laravel uses the Model View controller or MVC format or structure so here in our project there's specific areas for those types of things so there's specific areas for the modal there is a specific area for the view and specific area for our controllers so we're going to get to that later on on this blog and if we try to open the app folder here we can see the user that PHP file which is this is actually a modal and we won't go through the code right now but this particular file is a user or I mean a model user that PHP and we can add all the models here inside the app folder but we can actually use or we can actually have a another folder here so you can add project folder here and try to name it as models if we have if we have like 50 or 100 models for our project so we can add a subfolder for this app folder but if you have only maybe less than 10 or less than 20 models you can just leave it here inside the app folder and also if you try to open up the folder and under HTTP and then controllers here we can see the base controller that PHP which is extending the base controller and all the methods and functions of this base controller we can use it in our controller files and also learn creates a folder for the other controllers such as the lagging controller register controller and reset password controller so all of these controllers we can use we can use this readily if we try to enable the oath for our project and if we try to create a controller we can actually manually create a file here or that PHP file which is for our controller and also we can use or we can create a model by just manually adding it here but the best way for adding controllers and and the model is by using the artisan now if you're wondering what is this namespace name space app so this is just basically grouping our classes or our cold so this is a pretty common if especially if you're working the object-oriented way of programming so we're just basically grouping or our classes and try to distinguish between different classes and the same classes inside this directory and also if you see the illuminate here don't get confused it is just basically a core files or core functions coming from the laravel so don't worry about this now views are gonna be on the resources folder and under resources juice and then here we have the Welcome that laid that PHP and as we all know that laravel uses the blade template in system so it is just basically a HTML with dynamic mechanism in them so we can see if statement we can see loops we can see variables by using the rating system okay so now that we get that out of the way we can go to basic routing for our project so basically we're what we want is to add a pages controller where we can add we about pages home pages contact or any other page that we want to add in our project so if you try to go to our project and routes here and when you can see we can see here that we have gear out and Colin Colin and then the type of request that we want and then the URL and of course the function that return something or put a lot of operation inside this function so try that for now and let's try to open up our project in a browser so here is our project and PK project that LOC slash so here's the home page where we can see all the links and the title laravel now let's try and go back to our code and try to edit and instead of our returning the Welcome we can just return something like attacks or string so return HelloWorld something like this and then save and let's go back to our browser and refresh so as you can see we have here the hello world tax that we can see and it is coming from our router or route and get and then the URL which is the slashes represent the home page of our project and of course the string hello world okay so for now let's copy this and let's just return this to the original or our index so this is the homepage of our app or application and this will be the hello page of our project so this is basically we're just going to display hello world and we can just we can also add HTML tag in here so just like that and then save and let's go back to our browser and in refresh so P key project that LOC this will be the home page right and we try to add hello here it will display our update and hello world string and this is where dh1 tab now if you are trying to submit the form or you are going to delete something so you can just change this into post if you are submitting via form so working with the route is very easy so say for example we have pages in our project and let's try to go to where is it resources and then we want to separate our pages here so let's just add a pages folder and in this folder we're going to create another file which is the name of our file will be the about about laid that PHP okay so in order about that lay that page people can just say about okay save that one and let's go back to our route file and instead of I think we're just going to change this and to get then let's just stop B and paste this here so instead of hello so we're just going to name it about or the URL will be slash about in the set of returning the HTML so we're going to return the view now and notice that we have the the about view inside our pages folder so we're just going to add pages and then add that or period they're there and then the keyword about so let's try it save the file and let's go back there about okay so here we are at our browser and instead of using the low let's change it into a brown so as you can see here we have the about word here that is coming from our about that late that page be fine and also there are times that we need to submit dynamic values in our request so say for example we want to submit or we want to request user with this particular ID so let's go back to our web page B file and let's just copy this so instead of just using the about let's change it I think for a change the two users and then in order for us to be able to submit an ID so we can just add a placeholder here and this will represent our ID and inside our function it should have a parameter ID that represents the idea of the user so instead of returning the view for now let's just display this is a user and then we're just going to add the name or the ID of the user so let's just save this and go back to our browser and refresh so instead of using the about so let's go ahead and try to open up the users and let's try to submit esteem so this is a user 15 or suffer sample name name of the user as Jo this is a user is Jo but most of most of the time warriors we are requesting a particular ID and then based on that ID we can clearly that into our database all right guys I think that's it for this particular blog and in the next blog we're going to discuss how to create controllers inside our laravel project thanks
Post a Comment