Skip to content

Commit

Permalink
Newsletter
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet committed Nov 13, 2023
1 parent c864971 commit 1144832
Show file tree
Hide file tree
Showing 9 changed files with 1,252 additions and 726 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ ALGOLIA_INDEX_NAME=

ALGOLIA_CRAWLER_ID=
ALGOLIA_CRAWLER_USER_ID=
ALGOLIA_CRAWLER_API_KEY=
ALGOLIA_CRAWLER_API_KEY=

MAILCOACH_API_TOKEN=
MAILCOACH_API_ENDPOINT=
MAILCOACH_LIST_UUID=
34 changes: 34 additions & 0 deletions app/Http/Controllers/NewsletterController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Http\Controllers;

use App\Documentation;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use ProtoneMedia\Splade\Facades\SEO;
use ProtoneMedia\Splade\Facades\Toast;
use Spatie\MailcoachSdk\Facades\Mailcoach;

class NewsletterController
{
public function create()
{
return view('newsletter', []);
}

public function store(Request $request)
{
$data = $request->validate([
'email' => 'required|email',
]);

Mailcoach::createSubscriber(
emailListUuid: config('mailcoach-sdk.list'),
attributes: [$data + ['tags' => 'Splade.dev']]
);

Toast::success('You have been subscribed to the newsletter!');

return to_route('home');
}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"protonemedia/laravel-mixins": "^3.3",
"protonemedia/laravel-splade": "^1.2.15",
"spatie/laravel-google-fonts": "^1.2",
"spatie/laravel-honeypot": "^4.3",
"spatie/laravel-mailcoach-sdk": "^1.1",
"spatie/laravel-sitemap": "^6.2",
"symfony/process": "^6.1",
"symfony/yaml": "^6.1",
Expand Down Expand Up @@ -75,4 +77,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
Loading

0 comments on commit 1144832

Please sign in to comment.