Code Monkey home page Code Monkey logo

affiliates-spark's Introduction

AffiliatesSpark

An affiliates package for Laravel Spark that allows you to track referrals from affiliates and pay commission.

Installation

Cashier 10+ / Laravel 6+ is supported in the 1.* releases. To use older versions, use one of the 0.* releases.

To get the latest version, simply require the project using Composer:

$ composer require keithbrink/affiliates-spark

Configuration

  1. In your User model, add the Affiliate trait:
use KeithBrink\AffiliatesSpark\Traits\Affiliate as AffiliateTrait;

class User extends SparkUser {
    use AffiliateTrait;
    ...
}
  1. In your SparkServiceProvider, add the following functions to handle adding affiliate IDs to the database:
Spark::createUsersWith('KeithBrink\AffiliatesSpark\Interactions\SaveAffiliateOnRegistration@createUser');
Spark::createTeamsWith('KeithBrink\AffiliatesSpark\Interactions\SaveAffiliateOnRegistration@createTeam');

or, if you want to add extra data to your user registration, use the interaction directly:

use KeithBrink\AffiliatesSpark\Interactions\SaveAffiliateOnRegistration;
...
Spark::createUsersWith(function ($request) {
    $extra_data = [
        ...
    ];

    $interaction = new SaveAffiliateOnRegistration;
    return $interaction->createUser($request, $extra_data);
});
  1. Add a link for affiliates in the menu dropdown. Edit \resources\views\vendor\spark\nav\user.blade.php, and under the Developer menu item (line 65), add the following code:
@if (Auth::user()->isAffiliate())
    @include('affiliates-spark::nav.affiliate-menu-item')
@endif
  1. Add a link for managing affiliates in the Kiosk menu. Edit your \resources\views\vendor\spark\kiosk.blade.php, and under the Metrics Link item (line 30), add the following code:
<!-- Affiliates Link -->
@include('affiliates-spark::nav.affiliate-menu-item-kiosk')

and in the same file under Tab Cards, add the following code:

<!-- Affiliates Tab -->
@include('affiliates-spark::nav.affiliate-tab-item-kiosk')
  1. Publish the package javascript with the command: php artisan vendor:publish --provider="KeithBrink\AffiliatesSpark\AffiliatesSparkServiceProvider" --tag=javascript. Then, in your /resources/js/app.js, require the package javascript:
require('./affiliates-spark/bootstrap');

Remember to compile the assets with npm run dev.

  1. Publish the package views with the command: php artisan vendor:publish --provider="KeithBrink\AffiliatesSpark\AffiliatesSparkServiceProvider" --tag=views. You should enter instructions for your affiliates in /resources/views/vendor/affiliates-spark/affiliates/instructions.blade.php.

  2. Run the package migrations with the command: php artisan migrate --package "keithbrink/affiliates-spark.

Optional Configuration

  1. If you would like your customers to see the discount they are receiving from an affiliate on the subcription page, in your resources/views/vendor/spark/settings/subscription/subscription-notice.blade.php file, after the @else statement (line 9), add:
@include('affiliates-spark::subscription.affiliate-discount')

Usage

  1. On any page that you would like to credit affiliates for sending people to, add the script: <script async="" src="/a-s/aff.js"></script>. You can also add the script to a different subdomain of the same top-level domain by making the src URL absolute rather than relative.

License

SegmentSpark is licensed under The MIT License (MIT).

affiliates-spark's People

Contributors

keithbrink avatar ricoxor avatar samtlewis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.