Giter Site home page Giter Site logo

php-mlm-matrix's Introduction

MLM Matrix

Latest Version Software License Total Downloads

Library for working with MLM matrices.

Did you find an error?

If you found an error in the code or grammatical mistake or any inaccuracy, please create new issues.

What is the MLM matrix?

Among the many MLM compensation plans available today, the Matrix plan is among the most popularly recommended owing to its uncomplicated structure. As it is quite simple in understanding it is considered very useful and resourceful and can be easily integrated into the MLM business.

To understand the Matrix plan, it makes sense to first understand its structure. The matrix
has fixed numbers of rows and columns, organizing the numbers in a particular width and depth. Typically, most MLM Matrix plans follow two types of structures; 2x2 or the 3x3, but there are exceptions based on company requirements. All the members in a Matrix Plan are positioned serially from top to bottom or left to right.

demo

After the matrix is filled, user at level 1 receives a reward and the matrix itself is divided into several matrices (depends on matrix pow, for example the cubic matrix will be divided into 3 new matrices). After that, new matrices wait for filling and cycle is repeated.

Install

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require --prefer-dist nepster-web/php-mlm-matrix "*"

or add

"nepster-web/php-mlm-matrix": "*"

to the require section of your composer.json file.

Structure

  • demo - Library demo
  • doc - Documentation files for GitHub
  • shema - Sample database table schema (MySQL)
  • src - Main library code
  • tests - Unit tests

Usage

Creating a new matrix object:

use Nepster\Matrix\Matrix;

$matrix = new Matrix(3, 2);

Getting information about the matrix:

$matrix->getDepth();
$matrix->getPow();

Get matrix array:

$matrix->toArray();

Managing users in the matrix:

use Nepster\Matrix\Coord;
use Nepster\Matrix\Matrix;

$matrix = new Matrix(3, 2);

$matrix->addTenant(null, function() {
    // return your user data
})

$matrix->addTenant(new Coord(1, 1), function() {
    // return your user data
})

$matrix->hasTenant(new Coord(0, 0));
$matrix->hasTenant(new Coord(1, 1));

$matrix->removeTenant(new Coord(1, 1));

Check the correctness of coordinates:

$matrix->isValidCoord(new Coord(0, 0));

Check if there are free positions in the matrix:

$matrix->isFilled();

For more examples, see the demo file.

How can I use database for matrices?

Based on the different specifics of mlm projects and web development tools, this library implements only the algorithm of operation of mlm matrices without storage support.

However, if you works with the database you can easily implement keeping and restore of matrix objects. You can study the example in the file MySQL schema.

For example, create a new service that allows you to write and/or restore the matrix object from the database:

class MatrixService {

    public function findById(int $id): Matrix
    {
        // You need make a query to the `matrix` table that find the required record
        // Use join or another query to retrieve user data from the `matrix_users` table
        // Initialize new Matrix object
        // Using `addTenant` method that add users to Matrix object (based on data from `matrix_users` table)
        // Return the proper Matrix object
    }

    public function save(Matrix $matrix): void
    {
        // Get the matrix array using the `$matrix->toArray()` method
        // Create a valid request to save data to the database
        // - Most likely in a relational database you will have 2 tables (matrices and matrix_users)
        // - Don`t forget to check a new matrix is being created or edited an already existing matrix
        
        // Note1: Write down users with depth and number for further recovery
        // Note2: Don`t write coordinates with empty positions to the database.
    }

}

Testing

$ phpunit

or

$ vendor/bin/phpunit

License

This library is licensed under the MIT License - see the LICENSE file for details.

php-mlm-matrix's People

Contributors

nepster-web avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-mlm-matrix's Issues

i want to integrate MLM Matrix.function

thanks for your reply sir..am using pure PHP of a membership script with i want to integrate MLM Matrix.function with, cos am a beginner it too logical for me to understand how to integrate MLM Matrix.i saw your script which i like the database table but i dont understand the matrix.php file, please sir can you just show me how to add data of user in Matrix table and there downline and also query matrix_users table...thank God bless you

Спасибо за ответ sir..am с использованием чистого PHP скрипта членства с я хочу, чтобы интегрировать MLM Matrix.function с, потому новичок это слишком логично для меня, чтобы понять, как интегрировать MLM Matrix.i увидел сценарий, который я люблю таблица базы данных, но я не понимаю, файл matrix.php, пожалуйста, сэр, вы можете просто показать мне, как добавить данные пользователя в матричной таблице и там нижестоящих, а также запрос matrix_users таблицу ... слава Богу благословить вас

Есть ли "перелив" в матрицах?

Здравствуйте!
У меня к вам два вопроса.

1.Обычно в бинарных (2х2) и троичных (3х3) матрицах есть так называемый "перелив", когда партнер привлекает больше партнеров первой линии (больше 2 или 3), то эти новые партнеры регистрируются под одним из партнеров его первого уровня... в Вашей библиотеке такое реализовано? В описании не нашел, а в код глубако не вникал.

  1. Как подключить библиотеку на сайт с реализацией через MySQL? Не сильно знаком с композером и его использованием, при этом Ваши рекомендации 2016 года посмотреть на http://demo.nepster.pro/matrix/ на данный момент не актуальны, сервер выдает 404 ошибку.

Need Help

Im Using Laravel as my Framework to Implement Your Script.
What i Did Was Put the Matrix.php in My MODEL.

users->hasmany(LINKS)
links->hasmany(matrix)

with this kind of relationship

i did this coz i want to have 1 user that can purchase many link to fill up the matrix.

Render.php to RenderController
Just implement Matrix namespace

use App/Matrix;

While Your Matrix.Sql to Laravel Migration Create_matrix_table , Create_matrix_links_table and create_matrix_type_table

Can You Provide me a Demo site? where all the function is working.
Or a Procedural Way to Implement each function
So i will know What a Function Do, and How i can Render it properly and integrate with properly with laravel.

Looking Forward for Your Reply

Mysql schema

Hi, I noticed there are 2 fields in matrix_users table, namely depth and number. May I know what should we put in number?? Is it the number of the position?

Не понимаю как работает матрица

Привет,

В основном работаю с Codeigniter, есть задача сделать матрицу с выплатами, чем выше уровень тем выше выплата, как мне правильно использовать твой код, для реализации этой функции?

С уважением.
Евгений

help wanted

Thank you so much for providing this code repository.
Can you please provide sample code to handle Matrix plan with a database like MySQL?

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.