I have created a model, where i have added this function:
public function behaviors() {
$this->scenario = 'test';
}
public function showlist()
{
if($this->scenario == 'test') {
die('yes');
}else{
die('no');
}
}
i have created a controller for get json result in this way:
<?php
namespace app\controllers;
use yii\rest\Controller;
use yii\data\ActiveDataProvider;
use app\models\Articoli;
class PartnumberController extends Controller
{
public function actionIndex()
{
return new ActiveDataProvider([
'pagination' => false,
'query' => Articoli::showlist(),
]);
}
}
When i try the script, i got this error into controller:
[font="monospace"][size="2"]Getting unknown property: app\controllers\PartnumberController::scenario[/size][/font]
[font="monospace"] [/font]But the scenario properties is into model no into [font="monospace"][size="2"]Controller[/size][/font][size="2"]!!![/size]
I don’t understand
Can you help me?