2020-01-24 11:04:48 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace console\controllers;
|
|
|
|
|
|
|
|
|
2024-02-01 00:57:42 +03:00
|
|
|
use common\models\Reports;
|
2020-05-22 16:42:24 +03:00
|
|
|
use common\models\UserCard;
|
2020-01-24 11:04:48 +03:00
|
|
|
use Yii;
|
|
|
|
use yii\console\Controller;
|
|
|
|
|
|
|
|
class SqlController extends Controller
|
|
|
|
{
|
|
|
|
public function actionSalary()
|
|
|
|
{
|
|
|
|
$sql = "UPDATE user_card SET salary=REPLACE( `salary`, ' ', '' )";
|
|
|
|
Yii::$app->db->createCommand($sql)->execute();
|
2020-01-24 12:05:34 +03:00
|
|
|
echo "script completed successfully\n";
|
|
|
|
}
|
|
|
|
|
2021-08-16 17:32:31 +03:00
|
|
|
public function actionAddAva()
|
|
|
|
{
|
|
|
|
$model = UserCard::find()->all();
|
|
|
|
foreach ($model as $item) {
|
2024-02-01 00:57:42 +03:00
|
|
|
if (!$item->photo) {
|
|
|
|
if ($item->gender === 1) {
|
2021-08-16 17:32:31 +03:00
|
|
|
$item->photo = '/profileava/f' . random_int(1, 6) . '.png';
|
2024-02-01 00:57:42 +03:00
|
|
|
} else {
|
2021-08-16 17:32:31 +03:00
|
|
|
$item->photo = '/profileava/m' . random_int(1, 10) . '.png';
|
|
|
|
}
|
|
|
|
$item->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "script completed successfully\n";
|
|
|
|
}
|
|
|
|
|
2020-01-24 12:05:34 +03:00
|
|
|
public function actionGenerateUser()
|
|
|
|
{
|
|
|
|
echo UserCard::generateUserForUserCard() . "\n";
|
2020-01-24 11:04:48 +03:00
|
|
|
}
|
2024-02-01 00:57:42 +03:00
|
|
|
|
|
|
|
public function actionAddUserIdToReports()
|
|
|
|
{
|
|
|
|
$reports = Reports::find()->all();
|
|
|
|
foreach ($reports as $report) {
|
|
|
|
$report->user_id = $report->userCard->id_user;
|
|
|
|
$report->save();
|
|
|
|
echo "user $report->user_id changed\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "script completed successfully\n";
|
|
|
|
}
|
2020-01-24 11:04:48 +03:00
|
|
|
}
|