mirror of
https://github.com/janickiy/yii2-nomer
synced 2025-03-09 15:39:59 +00:00
add files to project
This commit is contained in:
commit
5cac498444
3729 changed files with 836998 additions and 0 deletions
46
modules/admin/controllers/PlatiController.php
Normal file
46
modules/admin/controllers/PlatiController.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
namespace app\modules\admin\controllers;
|
||||
|
||||
use app\components\coupon;
|
||||
use app\models\PlatiCode;
|
||||
use yii\data\ActiveDataProvider;
|
||||
|
||||
class PlatiController extends AdminController {
|
||||
|
||||
public function actionNew() {
|
||||
$checks = \Yii::$app->request->get("checks");
|
||||
$count = \Yii::$app->request->get("count");
|
||||
|
||||
$codes = coupon::generate_coupons($count, [
|
||||
"length" => 12,
|
||||
"letters" => true,
|
||||
"numbers" => true,
|
||||
"symbols" => false,
|
||||
"mixed_case" => true,
|
||||
"mask" => "XXX-XXX-XXX-XXX"
|
||||
]);
|
||||
|
||||
$newCodes = [];
|
||||
foreach($codes as $code) {
|
||||
$platiCode = PlatiCode::find()->where(["code" => $code])->one();
|
||||
if($platiCode) continue;
|
||||
$platiCode = new PlatiCode();
|
||||
$platiCode->code = $code;
|
||||
$platiCode->checks = $checks;
|
||||
$platiCode->save();
|
||||
$newCodes[] = $code."<br>Для зачисления проверок введите код на сайте https://nomer.io/pay/coupon";
|
||||
}
|
||||
$file = \Yii::getAlias('@runtime')."/".uniqid("coupons").".txt";
|
||||
file_put_contents($file, join("\n", $newCodes));
|
||||
|
||||
\Yii::$app->response->sendFile($file);
|
||||
}
|
||||
|
||||
public function actionIndex() {
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => PlatiCode::find()
|
||||
]);
|
||||
|
||||
return $this->render('index', ["dataProvider" => $dataProvider]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue