This episode is for members only

Sign up to access "Build a File Marketplace with Laravel" right now.

Get started
Already a member? Sign in to continue
Playing
31. Creating and validating the product download page

Episodes

0%
Your progress
  • Total: 3h 32m
  • Played: 0m
  • Remaining: 3h 32m
Join or sign in to track your progress

Transcript

00:00
We finished up creating the sale, sending the email, now we need to allow the user to click on access files, go through to a page on our app which allows them to see all of the files and access these. So we're going to head over back to our main app because this is where we're going to create this page and let's create out a route here which is going to handle this for us.
00:20
So we're going to call this slash sales and then it's going to be the sale in here but it's going to take the token in, that's the reason we generated that token. Imagine if we had an id here that would be really easy to guess, so the token makes it a little bit harder for the sale page to be accessed by just anyone.
00:38
Okay so I'm just going to comment this out and we're going to generate out a controller in here, we can actually cancel off expose as well and we're going to make out a controller in here called sale show controller and let's create that out. So we can go ahead and hook this up now, sale show controller
00:56
and let's go ahead and give this a name, we'll call this sales.show. Okay so over in the sale show controller let's go ahead and create out an invoke magic method and for this we're just going to return a view and let's put them the sales and show. So let's create this page out really quickly, so under our views,
01:15
new folder called sales and show.blade.php. Okay so once again this is going to be a really simple page, let's just grab maybe the home page for this and we'll put that inside of here and we'll just write sale.
01:32
Okay so if we just come over to slash sales, let's go ahead and find out a sale token from in here, it can be any of these it doesn't really matter, but let's go ahead and just pop that into here and we see sale. So we know that this is successfully worked because if we just chose anything here
01:49
and we actually hooked up over in the sale show controller, the sale model being resolved out of the database, if we give that a refresh we get 404 not found. If we go back to this one, sure enough it's found, so we know that we now have a valid sale in here
02:07
which we can start to extract products from. What we could also do to make this page a little bit harder to guess is maybe add in the email address of the user who has purchased this. So I'm going to go ahead and add in the email address at the end here within the query string
02:22
and we could create out a really simple abort if and say that if the email address doesn't match here we're just going to kill the page. So let's go ahead and bring in our request object here and what this will do is it will abort the entire request,
02:40
much like you'd find if you just used something like abort in Laravel with some kind of status code if the condition in here is true. So we're going to go ahead and say request email which is what we just put in the query string and we're going to say if that doesn't equal the sale email we're going to abort with a 403.
02:59
So let's try this out, if we give this a refresh it works but let's say we had alex at cocos.co.uk we get a 403 forbidden. So that just adds another layer of protection onto what we have here just to make sure these two things match up and we can actually access the sale.
03:17
So let's go ahead and just pass the sale down into this template and let's just fill in a couple of details here. So the header at the top here let's go ahead and create out a maybe just a paragraph for this, so let's create a paragraph out here and let's just say thanks for purchasing
03:35
and we can say sale product title and just after this we'll say from and again because we've got all of our relationships set up we can make this a little bit more friendly with a bit more information, sale product user and name. So if we head over there we go.
34 episodes3 hrs 32 mins

Overview

Build a marketplace where sellers can list and sell files, while we take a cut of each sale using Stripe Connect.

We'll cover onboarding users with Stripe Connect, creating products and uploading files, payments, and delivering purchased files to your customers.

Here's everything we'll cover:

  • The Stripe Connect onboarding flow
  • Effortlessly creating products (and uploading files) with Livewire forms
  • Subdomains for your user's marketplace
  • Stripe Checkout for a beautiful, secure payment flow
  • Securely delivering files with Signed URLs in Laravel
  • Showing sales stats on a dashboard
Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.