Package Data | |
---|---|
Maintainer Username: | kevupton |
Maintainer Contact: | uptonkg@gmail.com (Kevin Upton) |
Package Create Date: | 2015-10-25 |
Package Last Update: | 2018-05-06 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-16 15:02:36 |
Package Statistics | |
---|---|
Total Downloads: | 408 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 1 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Laravel bare-bones implementation of a referral queue system. Currently the main functionality this package provides is the manipulation and creation of the referral queue.
This referral system is based of queue jumping. The idea being that when someone signs up they are placed into a queue. Then whenever someone registers, they jump X places in the queue. The idea behind the queue itself is that it is to slowly grow over a period of time, to simulate users signing up, and hence a demand. Or a queue to jump.
This file handles everything to do with the queue itself. A commend on each field is there explaining what each does.
<?php
return array(
//prefix to each of the tables in the database
'database_prefix' => 'ref_',
//how many uses to pretend we have at the start.
'start_at' => 1548,
//the number of positions jumped when a referral is made.
'jump_count' => 10,
//How often to add an extra fake referral
'addmore' => [
'interval' => 3600, //the time between each insert
'amount' => 1 //the amount to insert
]
);
This packages uses the Laravel Queue to manage the sign-up queue. It is broken into 2 key jobs.
The first being AddMore
and the second being MoveInQueue
.
This class handles adding more empty/fake subscribers to the queue itself. To use this class all you have to do
is call it once. Once it has run the first time it will continuously keep adding itself back to the queue, with the interval
time specified in referrals.addmore.interval
. Every time it runs it adds referrals.addmore.amount
subscribers to the queue.
Calling the job: $this->dispatch(new AddMore());
This class is responsible for moving a ReferQueue item to new position. It will move the queued_item to the new position and readjusting all the queued people in between.
Calling the job:
//just get the refer queue with id 200
$refer_queue = ReferQueue::find(200);
//get the new position
$new_pos = $ref_queue - ref_jumps();
if ($new_pos < 0) $new_pos = 0;
$this->dispatch(new MoveInQueue($refer_queue, $new_pos));
This model represents a queued item. The refer_queue
table is the pending queue for the system. So whenever someone refers someone
this is the queue that they jump. The user_id
in this class refers to the actual subscriber. So you just have to choose the id to use
for this value, whether it is on the users
table by default or a custom subscribers
table;
it will just refer to the primary key of whichever table you use.