تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Move Partials into Layout0:00

The next detail that I want to address are the partial views or the remaining partial views because we've converted everything to components except for the navigation and the aside. So let's do that in this episode. Now we're gonna do more than just convert the navigation and the aside. These are all included inside of the individual views and there's really no reason to do that anymore.

These are all included inside of the individual views and there's really no reason to do that anymore. We should just put those inside of the layout so that here we would have our navigation and then we would have our slot and then we would have the aside and that's it. And really too, you know, when it comes to the navigation, we conditionally showed the post button. Where do we do that? Right here. Well, I think we did that in a variety of places.

Route-Based Post Button0:54

Where do we do that? Right here. Well, I think we did that in a variety of places. Really the only place that we want to hide that post button is on the homepage where we display the timeline. The route is posts.index. So I think we could get rid of, you know, that flag, this showPostButton and just show or hide it based upon the route. Makes sense? So let's do that. Uh, so inside of all of these views, we're gonna get rid

Remove View Includes1:20

Makes sense? So let's do that. Uh, so inside of all of these views, we're gonna get rid of these includes because we don't need those anymore. And let's see, there's four views that we have to touch to do that. So we have two show views, then we will have the index. And really once we make this change, we should close these just so that I don't get confused because I will get confused.

we should close these just so that I don't get confused because I will get confused. So we're done with the show, then we have the index, in which case we want to get rid of that there. And then was that it? Surely that's not it. Surely that's not it. Uh, if we take a look at posts, we did index. Yep, that's done. We did show, oh, we need to do replies. So let's open up replies so that we get rid of those includes and then yep, we will go from there.

Convert Partials to Components2:08

So let's open up replies so that we get rid of those includes and then yep, we will go from there. So that then it's just a matter of creating this navigation and this aside. And really we don't need to create those because there there's really not much that we need to do. So what we are going to do is we're gonna take those two files, let's just drag 'em up to components and then yeah, that that's gonna be it.

let's just drag 'em up to components and then yeah, that that's gonna be it. Although we do need to do something inside of navigation. So down here where we were checking if that showPostButton variable was set, we're gonna change this to an if statement. So that we will call request()->route() and if it is not posts.index, then we want to show it. Yeah. So that is going to work for us.

to show it. Yeah. So that is going to work for us. So that we just need to scroll down a little farther so that we can replace that isSet with the if statement and then we will close out that if statement and that's it. Everything else should work. So that if we do a sanity check, sure enough, it looks like everything works. Although let's do this, let's change the home link and we want that to go to our home, which is the route

Delete Obsolete Views and Routes3:17

Although let's do this, let's change the home link and we want that to go to our home, which is the route of posts.index. So if we see that URL, yes we do. So now I just want to delete files. We want to keep our components, but we don't need these partial views anymore. So let's delete those. And really we don't need this feed, this profile.

And really we don't need this feed, this profile because these are views that are now used elsewhere, or at least they were replaced elsewhere. So let's get rid of those and that is gonna be great. But then there's that other profile view that I don't remember how that got there, but we will delete that so that now everything is either a component or it is inside of our posts or profiles.

that now everything is either a component or it is inside of our posts or profiles. We'll keep the welcome view just because, but I do know that we had some routes that used those other views, you know, these original ones. So let's get rid of the feed route because we don't need that anymore and let's get rid of the profile route 'cause we don't need that anymore either. And um, yeah, we have cleaned up our files.

Next: Query Improvements4:28

'cause we don't need that anymore either. And um, yeah, we have cleaned up our files. So now the next details that I want to address are query related and we will look at that in the next episode.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟