B
B
bizzonaru2017-05-27 14:50:24
Yii
bizzonaru, 2017-05-27 14:50:24

Why, when I call the model method from the console, an error occurs on yii\console\Request::post()?

It is not clear why when I do from the console that an error occurs in this spirit. It seems like it wasn't there before.

<?php

namespace console\controllers;

use yii\console\Controller;
use \backend\models\Tests;

class SlugController extends Controller
{
    
    public function actionTests()
    {
        $this->InitTests();
    }
 
    private function InitTests()
    { 
        if(($data = Tests::find()->all()) !== null) {
            /*@var $model Tests */
            foreach ($data as $model) {
                $model->save(true);
            }
        }
            
    }
}


Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: yii\console\Request::post()'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-05-27
@webinar

It is obvious. Because there is no post() method in the yii\console\Request class, but it is in yii\web\Request , but these are two different classes.
Links lead to docks, see available methods. So watch the debug and look for where you are calling this method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question