kevupton / referrals
laravel 推荐系统
1.2.5
2018-05-06 04:38 UTC
Requires
- php: >=5.3
- kevupton/ethereal: ^2.4.8
- kevupton/laravel-package-service-provider: ^0.0.5
Requires (Dev)
- laravel/laravel: 5.5.*
- laravel/lumen-framework: 5.5.*
README
Laravel 简化版的推荐队列系统实现。目前此包提供的主要功能是推荐队列的操纵和创建。
工作原理
此推荐系统基于队列跳转。其想法是当有人注册时,他们会被放入队列中。然后每当有人注册,他们就会在队列中前进 X 个位置。队列本身的想法是随着时间的推移慢慢增长,以模拟用户注册,从而产生需求或跳转队列。
配置文件
此文件处理与队列本身相关的所有事情。每个字段旁边都有一个命令解释它做什么。
<?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 ] );
工作
此包使用 Laravel 队列 来管理注册队列。它分为两个关键工作:第一个是 AddMore
,第二个是 MoveInQueue
。
AddMore
此类处理向队列本身添加更多空/假订阅者。要使用此类,你只需调用它一次。一旦它第一次运行,它将不断将自身添加回队列,间隔时间由 referrals.addmore.interval
指定。每次运行时,它都会向队列中添加 referrals.addmore.amount
个订阅者。
调用工作: $this->dispatch(new AddMore());
MoveInQueue
此类负责将 ReferQueue 项移动到新位置。它将移动队列项到新位置,并调整所有在队列中的其他人员。
调用工作
//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));
模型
ReferQueue
此模型表示一个队列项。`refer_queue` 表是系统的待处理队列。因此,每当有人推荐某人时,这就是他们跳转的队列。此类中的 `user_id` 指的是实际订阅者。所以你只需选择要用于此值的 id,无论是默认的 `users` 表还是自定义的 `subscribers` 表;它将仅引用你使用的表的主键。