In docs guides there is example:
namespace app\controllers;
use yii\rest\ActiveController;
class UserController extends ActiveController
{
public $modelClass = 'app\models\User';
}
But i dont get it, how to work with actions.
For example:
DataBase has tables with many-to-many relationship (via Junction table).
Сomponent to work with the models and the formation of a common response from multiple tables according to the transmitted data. Can return an array, or an array of objects.
When use it in commands controller, it was like:
class LastTweetsController extends Controller
{
/**
* @param int $count
*
* @throws yii\base\InvalidConfigException
*/
public function actionIndex($count = 10)
{
/** @var TweetLastfinder $tweetLastFinder */
$tweetLastFinder = Yii::$app->get('tweetlastfinder');
/**
* @var TweetShow $tweetShow
*/
$tweetShow = Yii::$app->get('tweetshow');
// For show tweets into terminal:
$tweetShow->showLastTweetsJSON($tweetLastFinder->findLastTweets($count));
}
}
But how i can make same operation in ActiveController (Transmit parameter $count and return result in JSON)?