2017 © Pedro Peláez
 

library heyloyalty

Helper for Laravel 5 that allows easy management of a HeyLoyalty member list.

image

hughwilly/heyloyalty

Helper for Laravel 5 that allows easy management of a HeyLoyalty member list.

  • Wednesday, February 8, 2017
  • by sydgren
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

HeyLoyalty Laravel Helper

Build, (*1)

This is a package for Laravel 5 that allows easy management of a HeyLoyalty member list., (*2)

Features

  • Subscribe
  • Unsubscribe
  • Update HeyLoyalty with latest data from Eloquent model
  • Update custom fields
  • Check subscription status

Installation

In your config/app.php file, add this line to the list of providers:, (*3)

Hughwilly\HeyLoyalty\HeyLoyaltyProvider::class,

Optionally, you can add this line to the list of aliases:, (*4)

'HeyLoyalty' => Hughwilly\HeyLoyalty\Facades\HeyLoyalty::class

Finally, to get the config file, run this artisan command:, (*5)

php artisan vendor:publish --provider="Hughwilly\HeyLoyalty\HeyLoyaltyServiceProvider" --tag="config"

Configuration

The default config file looks like this:, (*6)

<?php

return [
    'api_key' => null,
    'secret' => null,
    'list_id' => null
];

Get your api_key and secret from https://app.heyloyalty.com/settings/account and the list_id from the list you want to manage., (*7)

Usage

This package includes a trait (SubscribesToHeyLoyalty) to apply to your User model., (*8)

Apply this trait to by adding the following line at the top of the class:, (*9)

class User extends Model
{
    use Hughwilly\HeyLoyalty\Traits\SubscribesToHeyLoyalty;

    ...
}

This trait will add functionality to subscribe, unsubscribe and update the associated member in HeyLoyalty., (*10)

Examples

Subscribing

Let's say you run a webshop, and your customer went through the checkout flow and accepted receiving newsletters., (*11)

On the receipt page, you could do this in the controller:, (*12)

public function receipt(Request $request, Order $order)
{
    ...

    if ($order->subscribe_to_newsletter) {
        $order->user->subscribe();
    }

    ...
}

Updating

I recommend using Model Observers like so:, (*13)

class UserObserver
{
    ...

    public function updating(User $user)
    {
        $user->updateHL();
    }
}

And in your AppServiceProvider:, (*14)

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        User::observe(new UserObserver);
    }

    ...
}

Contributing

Feel free to make any changes/additions., (*15)

Fork the repository and submit a pull request, then I'll take a look at your code whenever I can., (*16)

The Versions

08/02 2017

dev-master

9999999-dev

Helper for Laravel 5 that allows easy management of a HeyLoyalty member list.

  Sources   Download

The Requires

 

The Development Requires

08/02 2017

1.0.0

1.0.0.0

Helper for Laravel 5 that allows easy management of a HeyLoyalty member list.

  Sources   Download

The Requires

 

The Development Requires