1 00:00:00,450 --> 00:00:01,490 Welcome back. 2 00:00:01,490 --> 00:00:06,250 In this section, we'll answer questions like, how is the Laravel homepage view 3 00:00:06,250 --> 00:00:11,382 displayed in the browser, and where exactly is the welcome view located? 4 00:00:11,382 --> 00:00:16,640 So far, we've used routes and closures to return basic math operations, 5 00:00:16,640 --> 00:00:19,630 string based responses, and the default welcome page. 6 00:00:20,710 --> 00:00:26,860 Imagine, we want to return to a specific page with HTML, CSS, and JavaScript. 7 00:00:26,860 --> 00:00:28,030 This is where the views come in. 8 00:00:29,450 --> 00:00:34,140 In the next few videos, we'll explore how views work, how to create them, and 9 00:00:34,140 --> 00:00:35,880 what we can do with them. 10 00:00:35,880 --> 00:00:38,710 Let's take a look at how this happens in closer detail. 11 00:00:40,180 --> 00:00:43,740 You already know how to display a view within a route, 12 00:00:43,740 --> 00:00:46,860 inside of the web.php file like this. 13 00:00:47,860 --> 00:00:52,490 This default route returned the Laravel welcome view located in the base path 14 00:00:52,490 --> 00:00:56,420 within the resources/views directory. 15 00:00:56,420 --> 00:00:57,220 This time, 16 00:00:57,220 --> 00:01:03,180 we want to create a function named index inside of the AppController.php file. 17 00:01:03,180 --> 00:01:04,415 In order to do this, 18 00:01:04,415 --> 00:01:08,788 let's return the welcome view inside of the index function like this. 19 00:01:21,403 --> 00:01:26,201 Instead of the index function, we want to return the welcome view like this 20 00:01:35,411 --> 00:01:40,434 Now that our AppController.php file is set to display the default welcome view, 21 00:01:40,434 --> 00:01:44,630 save your changes and head over to the routes directory. 22 00:01:44,630 --> 00:01:51,097 Next, open the web.php file and change the forward slash route destination to this. 23 00:02:02,241 --> 00:02:06,684 Notice that we're not using a closure, also known as an anonymous function. 24 00:02:06,684 --> 00:02:11,280 Because our forward slash route returns the index function 25 00:02:11,280 --> 00:02:14,710 inside of the app controller instead of the default welcome view. 26 00:02:16,120 --> 00:02:22,210 If this seems confusing, you can test this behavior by navigating to local host 8000. 27 00:02:22,210 --> 00:02:27,192 Remember, as we covered earlier, you can just adjust the port numbers if needed. 28 00:02:30,502 --> 00:02:33,710 If you see the welcome screen, great job. 29 00:02:33,710 --> 00:02:36,430 We're done creating our first controller for now, but 30 00:02:36,430 --> 00:02:40,070 we still need to build our views, so join me in the next section. 31 00:02:40,070 --> 00:02:40,590 See you there. 32 00:02:41,760 --> 00:02:47,360 Returning views from controllers is a crucial process in the Laravel ecosystem. 33 00:02:47,360 --> 00:02:51,800 It allows us to use routes to access controllers to perform some logic and 34 00:02:51,800 --> 00:02:56,600 then return an HTML page with the information retrieved from the database. 35 00:02:57,790 --> 00:03:01,250 If this sounds like MVC, then you're starting to get it. 36 00:03:01,250 --> 00:03:05,530 If not, keep going and it will make more sense as you keep learning. 37 00:03:05,530 --> 00:03:08,090 In the next section, we're gonna take a look 38 00:03:08,090 --> 00:03:11,730 at the differences between controllers and resource controllers. 39 00:03:11,730 --> 00:03:12,230 See you there.