public $login;
public $password;
public $role;
<?php
namespace app\models;
use yii\db\ActiveRecord;
class RegistrationModel extends ActiveRecord
{
public static function tableName()
{
return 'users';
}
public function rules()
{
return [
// username and password are both required
[['login', 'password', 'role'], 'required'],
];
}
public function attributeLabels()
{
return [
'login' => 'Логин',
'password' => 'Пароль',
'role' => 'Роль пользователя',
];
}
}
public function actionCreate()
{
$registrationModel = new RegistrationModel();
if( $registrationModel->load( Yii::$app->request->post() ) && $registrationModel->save() ){
Yii::$app->session->getFlash('successRegistration', 'Пользователь успешно создан');
return $this->redirect(['view', 'id' => $registrationModel->id])
}
return $this->render('create', ['registrationModel' => $registrationModel]);
}
$news = News::find()->where('category_id=:id'[':id' => $id])->all();