L
L
Lomoson2015-06-04 15:49:18
Yii
Lomoson, 2015-06-04 15:49:18

How to call model from common\models in ActiveController REST api?

In api\modules\v1\controllers in the controller, I cannot instantiate a model that is in common\models. If this model is copied to api\modules\v1\models, then you can work with it. Help, please, I can’t understand what’s the catch ... The magic of namespace's ...
Model class:

<?php

namespace common\models;

use \Yii;

class Help extends \yii\db\ActiveRecord
{
    public static function tableName()
    {
        return 'help';
    }
}

In controller:
use \common\models\Help;

class CampaignController extends ActiveController
{
....
public function actionView($id)
    {
        Help::findOne($id);
}

And in the output Class 'common\models\Help' not found

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2015-06-04
@wiggle

Maybe app/common/Model?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question