-
app/Actions/HandlePurchaseAction.php
Open in GitHubuse App\Models\User; use App\Models\Purchasable; use App\Support\Paddle\PaddlePayload; class HandlePurchaseAction { // public function execute( User $user, Purchasable $purchasable, PaddlePayload $paddlePayload, ?Referrer $referrer = null ): Purchase { // if ($user->email) { Mail::to($user->email)->queue(new PurchaseConfirmationMail($purchase)); } return $purchase->refresh(); } // }
-
app/Mail/PurchaseConfirmationMail.php
Open in GitHubuse App\Models\Purchase; use Illuminate\Mail\Mailable; class PurchaseConfirmationMail extends Mailable { public function __construct( public Purchase $purchase ) {} public function build() { return $this ->subject("Getting started with {$this->purchase->purchasable->product->title}") ->to($this->purchase->user->email) ->markdown('mails.purchaseConfirmation'); } }