I have a form model as below…
namespace app\models;
use Yii;
use yii\base\model;
use app\helpers\generalHelper as general;
class SignupForm extends Model {
public $company_name;
public $first_name;
public $last_name;
public $email;
public $username;
public $password;
public $password_again;
/**
* Validation rules
* @return array An array of validation rules
*/
public function rules() {
return [
//........
];
}
//..........
}
I want to use the Yii DB connection inside a method in this class via the Yii::$app->db reference, but wondering what is the preferred way to set this to a property so that I can access via something like $this->db.
Aren’t all the properties within the class supposed to be reserved for form property names? If not, where is the best place to set it? Should I make a constructor?