console generate-user

This commit is contained in:
akosse 2020-01-24 12:05:34 +03:00
parent eb09f95ff8
commit c85a047f77
4 changed files with 9 additions and 14 deletions

View File

@ -162,17 +162,6 @@ class UserCardController extends Controller
return $this->redirect(['index']);
}
/**
* Lists all UserCard models.
* @return mixed
*/
public function actionGenerate()
{
$massage = UserCard::generateUserForUserCard();
return $this->render('generate', ['massage' => $massage]);
}
/**
* Finds the UserCard model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.

View File

@ -161,8 +161,8 @@ class UserCard extends \common\models\UserCard
}
}
if ($user_card_array) return "Данные успешно сгенерированы";
else return "Нет данных для генерации";
if ($user_card_array) return "data generated successfully";
else return "no data to generate";
}
public static function getParameter($params, $key)

View File

@ -16,7 +16,6 @@ $this->params['breadcrumbs'][] = $this->title;
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Сгенерировать пользователей', ['generate'], ['class' => 'btn btn-success']) ?>
</p>
<?php

View File

@ -4,6 +4,7 @@
namespace console\controllers;
use backend\modules\card\models\UserCard;
use Yii;
use yii\console\Controller;
@ -13,5 +14,11 @@ class SqlController extends Controller
{
$sql = "UPDATE user_card SET salary=REPLACE( `salary`, ' ', '' )";
Yii::$app->db->createCommand($sql)->execute();
echo "script completed successfully\n";
}
public function actionGenerateUser()
{
echo UserCard::generateUserForUserCard() . "\n";
}
}