This episode is for members only

Sign up to access "Build a Referral System with Laravel" right now.

Get started
Already a member? Sign in to continue
Playing
22. Sending the payout email

Transcript

00:00
Okay let's just quickly look at how we send the referral payout email to an admin and then we will look in the next episode how to generate the csv and then attach that to the email.
00:10
Okay so we'll start really simply just by creating out a mail so let's go and make out a referral payout mail class and then inside of this referral payout let's just take a look at what we've got so referral payout and here we go okay so we've got a subject pretty straightforward I'm just going to leave that as it is we've got the content you can either use mark down in here
00:32
or just defer to a view which we'll create in a minute and then really importantly it's our attachment section which is where we're going to be generating and attaching the csv that we need to pay out to so let's just create out a view really quickly for this email we're not going to bother filling this in too much so let's make a view and we'll call this referral payout we'll
00:50
put it under an emails directory okay so let's go and fill this in emails and referral payout and let's open up that referral payout email view and in here we'll just say pay out in there that's it we'll just keep that as that for now we're not really focused on the body okay so how we are going to send this email well we need some way to test this locally you might
01:14
already have something set up but let me go ahead and show you how I set up mail pit so I've already got this installed so let's go and just run mail pit you can install this on multiple operating systems and once you run that you're going to end up with a host running here so let's go and open this up really quickly in our browser and there we go any mail that we now send from laravel is
01:34
going to land directly into here so we'll need to configure this so let's go over to emv I think I already have this set to 127.0.0.1 but you just want to make sure the port's 1.0.2.5 and you have your local host running like this okay we should be able to send an email now so let's go ahead and do this and we will send this to an admin now I'm not going to hard code this in here I'm going
01:55
to add this to our referral config really importantly so if this needs to change later it's very easy and we are just going to send over that new referral payout email and a little bit later we're going to send these records down to that so then we can generate the csv and then attach so for now let's just comment out what we've got here and we'll just make sure that this
02:19
goes ahead and runs through okay so we're going to come over to our payout endpoint that we're using to test and if we head over to mail pit sure enough that email has been sent with that body and of course we want to actually attach a document to this generate out the csv and attach a document so let's go ahead and look at that next
24 episodes2 hrs 39 mins

Overview

Let's build a feature complete Laravel referral system, completely from scratch.

We’ll cover generating referral codes, setting a cookie to track the referral process, hooking up referrals to subscriptions and displaying detailed referral stats in a dashboard, so your users can see how they're doing.

On the admin side, we'll set up a job to automatically generate a CSV with all the amounts you need to pay out each month, automatically mark referrals as paid, and display historical referral payments for users.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

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