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']); 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. * Finds the UserCard model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * 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 "Данные успешно сгенерированы"; if ($user_card_array) return "data generated successfully";
else return "Нет данных для генерации"; else return "no data to generate";
} }
public static function getParameter($params, $key) public static function getParameter($params, $key)

View File

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

View File

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