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

Generating First Achievement0:48

Now this is going to be a very repetitive thing, so we'll do the first one together, and then I will hit fast forward to quickly generate the rest, only stopping for maybe interesting points that we should discuss. OK, so if I switch over to phpStorm, you'll see that my types directory is now empty. And if I go to the service provider, we'll empty out that section as well. Let's get started with that first one. Start your engines. All right. php artisan, make me an Achievement called start your engines. All right, so let's see.

Fixing Generator Paths1:12

phpartisan, make me an achievement called start your engines. All right, so let's see. Start in the wrong directory. That should be in types. We must have forgotten to update that. OK, let's go to the generator command, and I'm going to put that within the types directory. And you know what? We might need to update the stub as well. Laracasts achievements types. OK, sorry about that.

Setting Icon Defaults1:56

Or how about when you have completed your first Laracast lesson? All right, the icon. Yeah, now this is one thing I did notice. As I was saving all of these SVGs, I named them exactly what the name of the class will be. And we talked about this earlier. So maybe in a follow-up lesson, I'm going to make this a default. So if you don't provide the icon property, we will take the class name. We will lowercase it and add dashes between each new word. Anyways, until then, I'll do it manually.

Defining Achievement Qualifier2:21

We will lowercase it and add dashes between each new word. Anyways, until then, I'll do it manually. Now the qualifier. Well, I just have to check a User's completions and ensure that it's one or more. Now for the Laracast codebase, I have a completions relationship that will...we have a pivot table behind the scenes, and this will give me all of the lessons that the User has completed. So I could say, excuse me, I could say we'll make sure that the count is at least one. And there we go. We have our first achievement badge. However, we do have to visit our service provider and manually add that.

Registering in Service Provider2:51

We have our first achievement badge. However, we do have to visit our service provider and manually add that. And you know what? I bet that's something our generateAchievement command could do for us. But again, it's not something I offer at the moment, so I have to manually do it. So start your engines. And we've completed our first one. And if I switch over to the profile page, we do see that achievement show up here. Now once we're done, we'll have a big list over here, but yet at the moment, we have a single achievement, and of course I do qualify for that one.

Planning Defaults and Caching4:43

good progress. I now have roughly a dozen different achievement types for all of our users, and we'll keep growing that numbers. So yeah, we still have some more work to do. We want to set more sensible defaults in our Achievement class. We should maybe consider some basic caching, because remember, at the moment, whenever you new up a class, well, as part of that, in the constructor at the moment, we're doing one database query. So we can either extract this out to a method that we call, or we can leverage caching, so that we only run this query one time, and then it's all thrown in the cache, and we

So we can either extract this out to a method that we call, or we can leverage caching, so that we only run this query one time, and then it's all thrown in the cache, and we will never clear that cache until I add a new AchievementType. And as you can imagine, you'll get to a point where there are no achievements. So this will basically, for the lifetime of the site, be cached, and we will not run those queries. So yeah, still a number of things to get to work on, but I think we're making pretty decent progress. So I'll see you in the next lesson.

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