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
23. Listing the user's live products

Episodes

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

Transcript

00:00
So lastly, for the user's marketplace homepage, we want to list through all of the products that they have for sale.
00:06
Now, just before we go ahead and do that, I'm going to go ahead and create a product, of course. So I'm just going to keep this super simple and say product one. That slug will get generated and we'll say product one description.
00:20
And let's go ahead and set this to nine ninety nine. We'll set this one to live. Let's choose just a really simple file for this, create that out and we'll create another product that isn't live
00:30
because we need to make sure that we're not showing products that are not live. So we'll say product two description and let's set this to twelve dollars. OK, so let's not set that live. Let's choose another file here, create that product.
00:46
And we've now got two products. So if we head over to here and give that a refresh, of course, we don't see anything at the moment because we're not doing anything here. So let's go over to our subdomain home controller
00:55
and pass down the user's products. So the products come from the user. We know that we've got a relationship in here and we can just say get for now. We'll iterate through them and then we will fix this up to only show live products.
01:11
Now, underneath here, we're first of all going to check if any products actually exist so we can just say product count. We'll go ahead and stick an else in here just to show a message if you don't have any products.
01:24
And in here, we will go ahead and iterate through the products. We'll keep this super simple again with the design. We don't want this to be too complex. You can go ahead and style this up however you need.
01:34
So we'll go ahead and create a list item in here and we will iterate over each of the products. So for each product as product. And we'll go ahead and end the for each just under there.
01:49
And we'll go ahead now put the product title in here. And that should be just enough for now. Now, if we don't have any products, let's go ahead and create our paragraph inside of here.
01:59
And in here, we'll just say user name. Doesn't have any. Products. For sale.
02:11
Yet, that should just about do so. We've got the two products in here now. Let's just space these out a little bit by setting the. Space Y on this to four, and I think that's OK.
02:22
Great. OK, so these will eventually be anchors because, of course, we're going to want to link through to the actual product itself. So let's add that anchor in there for now and go ahead and set a class of text.
02:34
Indigo 500, just so we know it's a link. And for now, that is pretty much it. But of course, we need to update this. So we only show live products.
02:44
Now, there's a couple of ways we can do this. And that will get rid of product two, which is not live. But for stuff like this, I know that I'm going to need to reference this elsewhere if I'm listing some products.
02:55
So I like to create a scope for this so I can just do something like the following. It's also a little bit easier to read. So a scope allows us to overrun the model itself to create a link to the product. So let's go ahead and create a link to the product.
03:08
And I'm going to call this product. And I'm going to call this product. Scope allows us to overrun the model itself to find out a way to control this via the query builder.
03:19
So we're going to go ahead and create a method called live prefixed with scope into this. We're going to get a query builder and we can just say query and exactly what we just did where live true.
03:33
That allows us then to tuck this functionality away in the model and have something like the following. So if we go over and give that a refresh, sure enough, we get exactly the same thing. So now on our marketplace homepage, we can only see products that are live.
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.