PHP code example of victtech / lottery

1. Go to this page and download the library: Download victtech/lottery library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

victtech / lottery example snippets

regexp
Lottery::getAward();
regexp
PersonLottery::getAward($dataSource,$count);
$dataSource //数据源所有参与抽奖的人员,数组格式,
$count //中奖人数
 bash
    php artisan vendor:publish --tag=lottery.config
 bash
    //配置中奖的概率以及每个奖项的数目
    return [
    'awards'=>[
        //key 是奖项名称
        '一等奖'=>[
            'total'=>5, //奖项总数量
            'probability'=>30  //中奖概率,百分率.所有奖项百分率之外就是不中奖概率
        ],
        '二等奖'=>[
            'total'=>10,
            'probability'=>50
        ]
    ],
];

bash
    php artisan lottery:clearRecord //清除抽奖的奖项剩余信息
    php artisan lottery:clearPersonRecord //清除已经中奖的人员信息