Download the PHP package a2zwebltd/laravel-affiliate without Composer

On this page you can find all versions of the php package a2zwebltd/laravel-affiliate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-affiliate

Laravel Affiliate

Generic affiliate / revenue-share engine for Laravel โ€” opt-in workflow, monthly commission closure, admin adjustments, partner-initiated payout requests, immutable commission statements, Blade+Alpine and Livewire dashboards.

Packagist Version Downloads PHP Laravel

Features

Requirements

Installation

The service provider is auto-discovered. Publish migrations and run them:

Optionally publish config and views:

Quick Start

1. Implement RevenueResolver in your app

The package never queries your billing system directly โ€” you implement a thin adapter:

Bind it in config/affiliate.php:

2. Add the affiliate concern to your User model

This adds affiliatePartner() and affiliateLink().

3. Capture attribution on signup

In your registration controller (or a Registered listener):

The cookie is set automatically by the affiliate.capture middleware whenever a visitor lands on a page with ?aff=CODE.

4. Schedule monthly closure

In routes/console.php (or app/Console/Kernel.php):

That's it โ€” once a partner is approved and you ship referral codes, the engine will close commissions on the 1st of each month.

Usage Examples

Manual referral attachment (Nova action)

When a referral was missed (cookie cleared, signup race, manual import), use the Attach referral action on the AffiliatePartner Nova resource:

  1. Open the partner detail page in Nova.
  2. Run Attach referral โ€” provide an email or user ID, optional attributed_at (for backdating), and tick "Recalculate" to trigger the monthly closer for past months.
  3. The action enforces the referred_user_id UNIQUE constraint and config-driven self-referral / first-touch rules.

Programmatic equivalent:

Recalculate a single partner

Re-runs MonthlyCloser for partner user 1234 โ€” picks up new referrals, adjustments, or rate overrides without touching other partners.

Issue a commission statement

Statements are generated when an admin marks a payout request as approved (or via the Generate statement for period Nova action). Once issued they are immutable โ€” corrections happen via AffiliateAdjustment rows, never by editing the statement.

Nova Integration

If laravel/nova is installed, register the resources in your NovaServiceProvider:

Resources registered:

Bundled actions: Approve, Reject, Suspend, Recalculate commissions, Generate statement for period, Attach referral, Approve payout, Reject payout, Mark as paid, Issue statement, Mark statement paid, Cancel statement.

Configuration

All keys in config/affiliate.php can be overridden by environment variables. A few highlights:

Env Default Description
AFFILIATE_REVENUE_SHARE_BP 3000 Default commission rate in basis points (3000 = 30%).
AFFILIATE_MIN_REFERRED_USERS 2 Number of paying referrals required before a user can apply.
AFFILIATE_MIN_PAYOUT_CENTS 5000 Minimum balance required to request a payout.
AFFILIATE_ATTRIBUTION first_touch first_touch or last_touch.
AFFILIATE_WINDOW_MODE lifetime lifetime or windowed.
AFFILIATE_WINDOW_MONTHS 12 When windowed, how many months a referral keeps generating commissions.
AFFILIATE_COOKIE_TTL_DAYS 60 Attribution cookie lifetime.
AFFILIATE_ADMIN_EMAIL โ€” Address that receives admin notifications.
AFFILIATE_LAYOUT layouts.app Blade layout used by partner pages.
AFFILIATE_NOVA_USER_RESOURCE App\Nova\User Class used for BelongsTo user fields.

Per-partner rate overrides live on affiliate_partners.revenue_share_bp and take precedence over the global default for future commissions; historical rows keep their snapshot rate.

Architecture

Data model

Lifecycle

  1. Visit โ€” affiliate.capture middleware reads ?aff=CODE and sets a cookie.
  2. Signup โ€” host app calls ReferralAttributor::attributeNewUser() which writes an affiliate_referrals row (subject to UNIQUE on referred_user_id).
  3. Application โ€” qualifying user submits the apply form; AffiliatePartner row is created with status=pending.
  4. Decision โ€” admin approves/rejects via Nova; partner email is dispatched.
  5. Monthly close โ€” affiliate:close-month iterates approved partners, sums revenue from RevenueResolver, computes commission rows.
  6. Payout request โ€” partner self-serves; admin approves; MarkPayoutRequestPaid action runs the PayoutCompletionWorkflow which issues an immutable PDF statement.

Key services

Service Responsibility
ReferralAttributor Cookie/code attribution; manuallyAttach() for admin tools.
MonthlyCloser Idempotent close-month + per-partner recalc.
CommissionCalculator Per-partner-month โ†’ commission cents.
CommissionStatementGenerator / CommissionStatementIssuer Draft โ†’ issue lifecycle.
PayoutRequestService / PayoutCompletionWorkflow Approve/reject/pay flows.
EligibilityChecker "Can this user apply?" gate.
PartnerStatistics Cached KPI feed for the partner dashboard.

Routes

By default the package mounts a dashboard/affiliate route group with web,auth middleware:

Route Name Purpose
GET / affiliate.dashboard Partner dashboard (state-aware: no-partner / pending / approved / rejected / suspended).
GET /apply affiliate.apply.show Apply form.
POST /apply affiliate.apply.store Submit application.
PATCH /payout-details affiliate.payout-details.update Edit payout details after approval.
POST /payouts affiliate.payouts.store Request payout.
DELETE /payouts/{request} affiliate.payouts.cancel Cancel pending payout request.
GET /statements/{statement} affiliate.statements.show Partner-facing statement detail.
GET /statements/{statement}/download affiliate.statements.download Signed PDF download.

Disable the default routes by setting affiliate.routes.enabled = false and registering your own.

Localization

Every user-facing string passes through __() โ€” including Nova labels, notification subjects, Livewire flash messages, and the PDF statement template. The package ships no language files; the host app is expected to extract keys via its own pipeline (e.g. a translate:extract artisan command). Run your extractor over the package's src/ and resources/views/ paths to harvest all keys.

Testing

The test suite uses Pest + Orchestra Testbench and exercises the full closure lifecycle with stub revenue resolvers.

Contributing

Issues and PRs are welcome. Please open a discussion before tackling large changes โ€” the engine has a few non-obvious invariants (idempotent closure, immutable statements) that are easy to break.

Security

Found a vulnerability? Please email [email protected] rather than opening a public issue.

Credits

License

The MIT License (MIT). See the license field in composer.json.


All versions of laravel-affiliate with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
barryvdh/laravel-dompdf Version ^3.1
laravel/framework Version ^12.0|^13.0
rinvex/countries Version ^9.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package a2zwebltd/laravel-affiliate contains the following files

Loading the files please wait ...