PHPackages                             lopatin96/laravel-affiliate-program - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lopatin96/laravel-affiliate-program

AbandonedLibrary

lopatin96/laravel-affiliate-program
===================================

Laravel affiliate program

1.0.12(2y ago)14.1k1MITPHPPHP &gt;=8.1

Since Nov 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/lopatin96/laravel-affiliate-program)[ Packagist](https://packagist.org/packages/lopatin96/laravel-affiliate-program)[ RSS](/packages/lopatin96-laravel-affiliate-program/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

Install
=======

[](#install)

Before install composer, create a `resources/markdown/affiliate-terms.md` file in you project (see **Terms** section belowe).

### Terms

[](#terms)

Create a `resources/markdown/affiliate-terms.md` file with Terms of Service.

### Migrations

[](#migrations)

Run a migration `php artisan migrate`

### Directive

[](#directive)

Add a blade directive to `app/Providers/AppServiceProvider.php`

```
use Illuminate\Support\Facades\Blade;

public function boot()
{
    …
    Blade::directive('money', static function ($amountInCents, $decimals = 2) {
        return "";
    });
}
```

### Middlewares

[](#middlewares)

1. Add AffiliateProgram middleware to middleware array in `app/Http/Kernel.php`
2. moved these two lines (`\Illuminate\Session\Middleware\StartSession::class` and `\Illuminate\View\Middleware\ShareErrorsFromSession::class`) from `$middlewareGroups` to `$middleware`:

```
protected $middleware = [
    …
    \App\Http\Middleware\EncryptCookies::class,
    \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
    …
    \Atin\LaravelAffiliateProgram\Http\Middleware\AffiliateProgram::class,
];
```

### Listeners

[](#listeners)

Add `SaveAffiliateId` and `SparkAffiliateSubscriptionUpdate` to `app/Providers/EventServiceProvider.php`:

```
use Atin\LaravelAffiliateProgram\Listeners\SaveAffiliateId;
use Atin\LaravelAffiliateProgram\Listeners\SparkAffiliateSubscriptionUpdate;
…
protected $listen = [
    Registered::class => [
        SaveAffiliateId::class,
    ],
];

protected $subscribe = [
    SparkAffiliateSubscriptionUpdate::class,
];
```

### Trait and Casts

[](#trait-and-casts)

Add `HasAffiliate` trait to User model.

```
use Atin\LaravelAffiliateProgram\Traits\HasAffiliate;

class User extends Authenticatable
{
    use HasAffiliate;
```

Nova
----

[](#nova)

Add `NewAffiliateCommissions` and `NewAffiliateInvoices` to `app/Nova/Dashboards/Main.php`

```
public function cards()
{
    return [
        …
        new NewAffiliateCommissions,
        new NewAffiliateInvoices,
        …
    ];
}
```

### NovaServiceProvider

[](#novaserviceprovider)

```
MenuSection::make('Affiliate Program', [
    MenuItem::resource(AffiliateCommission::class)
        ->name('Commissions'),
    MenuItem::resource(AffiliateInvoice::class)
        ->name('Invoices'),
    MenuItem::resource(AffiliatePayout::class)
        ->name('Payouts'),
])
    ->icon('user-group'),
```

### Metrics

[](#metrics)

#### AffiliateCommissionsPerDay

[](#affiliatecommissionsperday)

```
