Wildcard Routes and Find 0:00So, let's see. In our routes file, we've registered two different routes, and we now have a single controller responsible for both of them. But now, specifically, I want you to take a look at this one. Here, we use a wildcard to represent any specific task. That way, it can be task slash one, or task slash a hundred. Now, in the controller, it accepts the ID, or whatever that wildcard is, and then it passes that ID to Eloquent's find method. So now, if we were to return this task directly, well, as we've already learned, Laravel will automatically convert that to a JSON response, which is great.So now, if we were to return this task directly, well, as we've already learned, Laravel will automatically convert that to a JSON response, which is great. One, two, three. However, here's something even cooler. What if instead of having to find this task, we instead just want to say, yeah, I expect a task here? That would be nice. But, could that work? I don't know. Let's switch back and refresh, and check it out. Introducing Route Model Binding 0:52I don't know. Let's switch back and refresh, and check it out. You get the exact same thing that you had before. This is called route model binding, and it's very cool. So here's the key components to understand. When registering a route, your wildcard, well, you want to make sure that that name matches up with your variable name. Or in other words, if we had it named the task, well, it's not going to work the way we'd expect. And that's because Laravel is actually checking this for you.we'd expect. And that's because Laravel is actually checking this for you. It's going to see, okay, we have a wildcard named task. And it's also going to see, well, is there a variable with that same name? And if so, I'm just going to find that record for them, because it looks like that's exactly what they want to do. So essentially, it's going to do a task find wildcard for you. Very cool, right? So come back, refresh, and now that works. So this means what we had at the beginning of the episode, right here, that may now be Simplifying Controller with Binding 1:40So come back, refresh, and now that works. So this means what we had at the beginning of the episode, right here, that may now be simplified to this. And we'll still get the exact same thing as we did before. Three, two, and one. Now one thing to keep in mind is that Laravel will assume a primary key. So in this particular instance, yeah, it's going to find the task that has an ID equal to that wildcard. However, should you need to, you can modify that. So you can specify that, for example, a post, well, we're going to reference it as a slug. Customizing Binding Key 2:07However, should you need to, you can modify that. So you can specify that, for example, a post, well, we're going to reference it as a slug. So maybe if you have a post slash post. Yeah, maybe that's going to be some post title slug rather than an ID. And if so, just rest assured, you can do that completely. It would just be a matter of updating one method on your post model. And we'll get to that eventually, but don't worry about it right now. It's not necessary. All right, so great job. In the next episode, let's move on to something new.All right, so great job. In the next episode, let's move on to something new.