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

Fix Factory Test Failures0:00

Let's run all the tests of this page, and some of them are failing now. Let's check what this is about. I already have an idea. Do you already have an idea what this could be about? Think about it for one to two seconds. And here we have it. Not null constraint for the pedalProductID. Yes, because we haven't added it to our factory. So we should have a CourseFactory. And here we're now going to add the pedalProductID. And by the way, I need to regenerate the helper code for Laravel Idea. And I think after that we should also have auto-completion here again.

And by the way, I need to regenerate the helper code for Laravel Idea. And I think after that we should also have auto-completion here again. Yes, we do. Which is pretty nice. So what we're going to add here... I think I'm going to go with a UUID, which is a string, and should also work. Let's run all the tests of our page course details test again. They are working. And let's also, of course, let's run all of our tests. And I think I saw some failing. Okay. Let's check what those are about.

Update Database Seeder Data1:08

And I think I saw some failing. Okay. Let's check what those are about. It does not add testUser for production. All right. Here we have the same issue with the pedalProductId. Let's check out which test this is. DatabaseSeederTest. All right. Oh, yeah. I already know what this is about. So here we are checking that after we are seeding that we have the right data inside our application. So this means if we check out the DatabaseSeeder,

that we have the right data inside our application. So this means if we check out the database seeder, here we are adding the courses, but we haven't provided the product ID yet. So that's what I'm going to do here. I don't think you need to watch it, but I'm just going to add here the real product ID to all the courses. All right. Let's run the test again. Now this works and now also all tests should work again. And they do. 63 tests already. Pretty amazing.

Add Homepage Course Links2:08

Now this works and now also all tests should work again. And they do. 63 tests already. Pretty amazing. All right. So this is working all from the test side. I think also we can now take a look inside the browser because also our button should now already work. And it seems like we don't have any links to the course details pages. Okay. I think we probably forgot about them. Okay. Good that we're here. Good that we also checked it through the browser. Let's try to bring them in as well. And here at the end of the page home test.

Let's try to bring them in as well. And here at the end of the page home test. Yes, here we want to make sure that we also see the links to the products, to the courses. It includes courses links. All right. So let's create two courses. First course, CourseFactory. Great. We don't care about any data. Let's add two more. Second course and the last course. If I can spell it correctly, here we go.

Second course and the last course. If I can spell it correctly, here we go. And now we want to make sure again, I think we can copy this. We don't need to be locked in. We make a GET request to the homepage. We want to make sure everything is okay. And then we want to make sure that we see some links here. So what's the first link? It should be courseDetails route. And here we're going to provide the first course.

It should be course details route. And here we're going to provide the first course. Yes, let's copy this. And then we're only going to change here. This is the second course and the last course. This should already do it. And this should already fail. Because here we don't have any links on our homepage. Let's give this a look. And it's true.

Let's give this a look. And it's true. So we're going to create here a new link. We're going to use our route helper to create a link to the course details page. And as an argument, we need to provide the course itself. Let's wrap our H2 title here inside this link. Let's run the test. And it's still failing. Let's see what this is about. Failed asserting that we have here only the login link.

Let's see what this is about. Failed asserting that we have here only the login link. Yeah, that's all we have in here. And we're not seeing the links ourselves. Okay, this means let me check here. We don't have any courses. Oh, yeah. I guess this is about because we haven't released them. So released. All right.

So released. All right. Let's run this again. Yes. And now this is working. And if we refresh the page, we now should see the links. Yes, we do. And now we also have access to the course details. And now here we see also our buy button here. Let's give this a look.

Configure Pedal Sandbox Mode5:03

And now here we see also our buy button here. Let's give this a look. Yeah, with the correct product ID. And let's see what happens now if we click it. Page not found. All right. So this is not exactly working as we expected yet. And that's because I'm using here the sandbox version of pedal. And this also means we have to tell this to the library. So here where we're going to set up pedal,

And this also means we have to tell this to the library. So here where we're going to set up pedal, we're going to have to provide the information that we're using the sandbox version of pedal. And you can also find this on working with the pedal sandbox. Here we have some information. And down here you will see that we need to set the environment to sandbox if you want to work with the sandbox version of pedal. So we need to do this here right before we're going to set up pedal itself. Let's try this now again.

So we need to do this here right before we're going to set up pedal itself. Let's try this now again. Click our buy button. And yeah, finally, we see here the checkout page now for our new level for beginners course. And just to be sure, let's also try here another one. And this one is also working. Cool. So we have successfully added here the checkout overlay from pedal to our courses.

Guard Sandbox Locally6:19

So we have successfully added here the checkout overlay from pedal to our courses. And we also made sure that this button is really available on the page. There's only one more thing left here inside our code because I only want to add this if we are working locally. Because, of course, when we are working in production, we don't want to set this. So this means we are going to wrap this inside an environmental check for if we are working locally, then we want to set this. And to be sure, let's see if this is still working.

for if we are working locally, then we want to set this. And to be sure, let's see if this is still working. No, it isn't. Let's see what have I done wrong here. Oh, yeah, this needs to be gone. Let's try it again. And this should still be working. And it does. All right, perfect. So now we've made sure that we can use the checkout button for our courses.

All right, perfect. So now we've made sure that we can use the checkout button for our courses. And in the next videos, we're going to move on finishing our purchasing a course feature. Thank you.

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