-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor registration validation rules * add terms and newsletter subscription checkboxes * add newsletter subscription * wip --------- Co-authored-by: Lupu Gheorghe <[email protected]>
- Loading branch information
1 parent
cbc55f1
commit 3868797
Showing
10 changed files
with
255 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services; | ||
|
||
use Spatie\Newsletter\Facades\Newsletter; | ||
|
||
class NewsletterService | ||
{ | ||
public static function subscribe(string $email, ?string $name = null) | ||
{ | ||
$mergeFields = [ | ||
'MERGE1' => $name, | ||
]; | ||
|
||
$options = [ | ||
'pending' => true, | ||
]; | ||
|
||
$response = rescue( | ||
fn () => Newsletter::subscribe($email, $mergeFields, options: $options), | ||
false | ||
); | ||
|
||
if (false !== $response) { | ||
// TODO: check if email registered as user | ||
// and assign subscriber badge if the | ||
// user doesn't already have one. | ||
} | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
return [ | ||
|
||
'driver' => env('NEWSLETTER_DRIVER', \Spatie\Newsletter\Drivers\MailChimpDriver::class), | ||
|
||
/* | ||
* These arguments will be given to the driver. | ||
*/ | ||
'driver_arguments' => [ | ||
'api_key' => env('NEWSLETTER_API_KEY'), | ||
|
||
'endpoint' => env('NEWSLETTER_ENDPOINT'), | ||
], | ||
|
||
/* | ||
* The list name to use when no list name is specified in a method. | ||
*/ | ||
'default_list_name' => 'subscribers', | ||
|
||
'lists' => [ | ||
/* | ||
* This key is used to identify this list. It can be used | ||
* as the listName parameter provided in the various methods. | ||
* | ||
* You can set it to any string you want and you can add | ||
* as many lists as you want. | ||
*/ | ||
'subscribers' => [ | ||
/* | ||
* When using the Mailcoach driver, this should be Email list UUID | ||
* which is displayed in the Mailcoach UI | ||
* | ||
* When using the MailChimp driver, this should be a MailChimp list id. | ||
* http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id. | ||
*/ | ||
'id' => env('NEWSLETTER_LIST_ID'), | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.