Download the PHP package mkeremcansev/laravel-commission without Composer

On this page you can find all versions of the php package mkeremcansev/laravel-commission. 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-commission

Package Image

What is Laravel Commission?

Laravel Commission is a powerful package designed to simplify the management and calculation of commissions within Laravel applications. This package provides a flexible and extensible system for defining various types of commissions, whether they are based on percentages, fixed amounts, or more complex criteria.

Key Features:

  1. Multiple Commission Types: Laravel Commission allows you to define various commission types, such as percentage-based, fixed amount, or a combination of both. This flexibility enables developers to tailor commission structures to meet specific business requirements.

  2. Dynamic Calculation: The package supports dynamic commission calculations based on the original product price or total price after applying other commissions. It accommodates different scenarios through the use of parameters such as is_total, min_amount, max_amount, and rounding.

  3. Comprehensive History Tracking: Laravel Commission provides functionality to track the history of commission calculations, allowing businesses to maintain an accurate record of commissions applied over time.

  4. Integration with Eloquent Models: The package seamlessly integrates with Laravel's Eloquent ORM, enabling developers to associate commissions with various models, such as products, orders, or services.

  5. Extensibility and Customization: Developers can easily extend the functionality of the package to create custom commission logic that suits their business needs. This makes it easy to adapt to different use cases and scenarios.

Use Cases:

In summary, Laravel Commission is a versatile and robust solution for managing commissions in Laravel applications, providing developers with the tools they need to implement and customize commission calculations effectively. Whether you're building an e-commerce site, an affiliate platform, or a sales management system, this package can help streamline your commission management processes.

Installation

You can install the package via composer:

You can publish the migrations with:

You can run the migrations with:

You can publish the config file with:

Usage

  1. Implement the Interface: Ensure that the model you want to apply commissions to implements the HasCommissionInterface. This interface defines the methods required for commission calculations.

  2. Use the Trait: Use the HasCommission trait within your model to gain access to the commission calculation methods.

  3. Implement the Method: Implement the getCommissionableColumns() method in your model to specify which columns can have commissions applied.

  4. Calculate Commissions: Use the calculate('price') method to apply commissions to your model.

    Note: If you want to calculate based on a custom value instead of using the column value, you can provide a second parameter to the calculate method. For example, $model->calculate('price', 100) will calculate the commission based on the value 100 instead of the price column value. For example;

Important Note

The calculate() method returns a \Mkeremcansev\LaravelCommission\Services\Contexts\CommissionCalculationResultContext or array or null.

Null: If the model getCommissionableColumns() method is return a empty array.

Array: If the model getCommissionableColumns() method has multiple columns. (Return array of \Mkeremcansev\LaravelCommission\Services\Contexts\CommissionCalculationResultContext)

CommissionCalculationResultContext: If the model getCommissionableColumns() method has only one column.

Adding Custom Pipes After Commission Calculation

1. Creating a CustomPipe Class

Create a pipe class that will run after the commission calculation is done. Each pipe class receives the commission calculation context in the handle method, allowing you to further process the result. In this example, we use the BaseCommissionCalculatorContext class as a type hint for the context:

2. Registering the CustomPipe Class

Add the CustomPipe class to the commission.pipes configuration array in the config/commission.php file. This configuration array defines the sequence of pipes that will be executed after the commission calculation:

If you want a commission not to be calculated after a specific date, refer to the following documentation:

Testing

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-commission with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0
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 mkeremcansev/laravel-commission contains the following files

Loading the files please wait ....