All Projects → mydnic → laravel-subscribers

mydnic / laravel-subscribers

Licence: MIT license
Manage Internal Newsletter Subscribers With Laravel. Vue Component included.

Programming Languages

PHP
23972 projects - #3 most used programming language
Vue
7211 projects
javascript
184084 projects - #8 most used programming language

Manage Internal Newsletter Subscribers With Laravel

Latest Version on Packagist Software License Build Status Code Quality

Installation

You may use Composer to Install Laravel Subscribers:

composer require mydnic/laravel-subscribers

The package will automatically register itself

You then must publish the migration with:

php artisan vendor:publish --provider="Mydnic\Subscribers\SubscribersServiceProvider" --tag="subscribers-migrations"

Usage

In your view, you simply need to add a form that you can customize the way you want

<form action="{{ route('subscribers.store') }}" method="post">
    @csrf
    <input type="email" name="email">
    <input type="submit" value="submit">
</form>

@if (session('subscribed'))
    <div class="alert alert-success">
        {{ session('subscribed') }}
    </div>
@endif

Delete

Simply provide this link to your subscribers:

<a href="{{ route('subscribers.delete', ['email' => $subscriber->email]) }}">unsubscribe</a>

This will generate a link like /subscribers/[email protected]

Subscribe manually from the user model

Alternatively, you can manage the subscription of a user from the user model.

In order to do that you will need to add the CanSubscribe trait

use Mydnic\Subscribers\Traits\CanSubscribe;

class User extends Model
{
    use CanSubscribe;
}
// subscribe user
$user->subscribe();

// unsubscribe user
$user->unsubscribe();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].