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

Refactoring into Types Folder0:24

Is this one? Kind of. Is this one? We need to scan the entire directory to parse out all of the various achievement types, like this one and this one. So with that in mind, why don't we instead place them within a new directory called types? Okay, so we'll take, I think we only have two at the moment, we'll take those as well as the abstract parent class, and we'll move them here. Okay. So now, I do think we have to update the namespace, so we'll do that here.

Updating Namespaces and Imports0:45

Okay. So now, I do think we have to update the namespace, so we'll do that here. And here. And one more. Okay, next, if we visit our AchievementServiceProvider, we need to import these. All right, that one and that one are now available. So I think the first step, probably some of our tests have broken. So let's go to our AchievementTypeTest and give this a run. Yeah, it fails. AchievementType not found.

Fixing Broken Tests1:15

Yeah, it fails. AchievementType not found. So again, that's because we have to update the namespace or the import here. We'll give it another run, and the class Achievement not found in AchievementType. Yeah, we have to fix that. All right, now it's available up here. We'll give it another run, and we do get green. Okay, great. Let's go to our GeneralAchievementTest right here, and we'll give that one a run as well. All right, everything's returning green.

Simplifying Service Provider Imports1:35

Let's go to our general achievement test right here, and we'll give that one a run as well. All right, everything's returning green. So that was an easy refactor. Now take a look. If I ever want to determine what achievements do we offer, I can now very easily open this directory and view all of them. Now one thing we might want to do if I go to AchievementServiceProvider, you can imagine if we had a bunch of achievement types, you know, maybe 15 or something like that, you would end up with this long list. So in these scenarios, if you want, you can just import the top level namespace, and then

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