Package Data | |
---|---|
Maintainer Username: | barnabaskecskes |
Maintainer Contact: | barnabas@riverskies.com (Barnabas Kecskes) |
Package Create Date: | 2017-09-05 |
Package Last Update: | 2022-06-17 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:01:39 |
Package Statistics | |
---|---|
Total Downloads: | 1,291 |
Monthly Downloads: | 4 |
Daily Downloads: | 0 |
Total Stars: | 16 |
Total Watchers: | 2 |
Total Forks: | 7 |
Total Open Issues: | 1 |
A simple package to enable newsletter subscriptions within the context of a Laravel application.
$ composer require riverskies/laravel-newsletter-subscription
Add the service provider to your config/app.php
file:
'providers' => [
// ...
Riverskies\LaravelNewsletterSubscription\Providers\NewsletterSubscriptionServiceProvider::class,
];
Include a simple form anywhere within your pages.
<form action="/subscribe" method="POST">
{{ csrf_field() }}
<input type="email" name="email"/>
<button type="submit">Subscribe</button>
</form>
You might also want to include notification display on the same page.
@if(session('flash'))
<p>{{ session('flash') }}</p>
@endif
This package collects email addresses and stores them in the database. You can access these subscriptions by querying the Riverskies\LaravelNewsletterSubscription\NewsletterSubscription
Eloquent model.
This package uses the Mail
facade to deliver the emails and delivery is queued, so ensure your QUEUE_DRIVER
in your environment config is set accordingly.
You can override the database table name, the associated URLs, email template format and the session key by overriding the default configuration values.
$ php artisan vendor:publish --tag='newsletter-subscription-config'
You can design the confirmation email by overriding the default view.
$ php artisan vendor:publish --tag='newsletter-subscription-views'
You can localise/change the messages by overriding the default localisation values.
$ php artisan vendor:publish --tag='newsletter-subscription-translations'
This package uses hashids/hashids
to help derive unsubscribe links from the id
fields of the subscription records. Those hashes are not stored in the database but instead encoded/decoded at runtime. To generate unique codes, this package uses the APP_KEY
from the environment settings. If that changes, previously generated unsubscribe links will no longer work.
PRs are welcome as long as they are following PSR-2
standards and include all the corresponding tests that the change requires (not to mention that those should not break any previous behaviour either).