hey there i am trying to create the login form in yii2 and i am new to yii2 framework i got an error like this
here it is my login model class
Blockquote<?php
namespace app\models;
use phpDocumentor\Reflection\Types\Self_;
use Yii;
use yii\web\IdentityInterface;
/**
-
This is the model class for table “seller_user”.
-
@property int $seller_user_id
-
@property string $seller_name
-
@property string $seller_email
-
@property int $seller_mobile
-
@property string $password
-
@property string $authkey
/
class SellerUser extends \yii\db\ActiveRecord implements \yii\web\IdentityInterface
{
/*- {@inheritdoc}
*/
public static function tableName()
{
return ‘seller_user’;
}
/**
- {@inheritdoc}
*/
public function rules()
{
return [
[[‘seller_name’, ‘seller_email’, ‘seller_mobile’, ‘password’], ‘required’],
[[‘seller_mobile’], ‘integer’],
[[‘authkey’, ‘seller_name’, ‘seller_email’, ‘password’], ‘string’, ‘max’ => 255],
];
}
/**
- {@inheritdoc}
*/
public function attributeLabels()
{
return [
‘seller_name’ => ‘Seller Name’,
‘seller_email’ => ‘Seller Email’,
‘seller_mobile’ => ‘Seller Mobile’,
‘password’ => ‘Password’,
];
}
/**
-
@inheritDoc
*/
public static function findIdentity($seller_user_id)
{
return self::findOne($seller_user_id);
}
/**
-
@inheritDoc
*/
public static function findIdentityByAccessToken($token, $type = null)
{
return self::findOne([‘accessToken’ => $token]);
}
/**
-
@inheritDoc
*/
public static function findByUsername($seller_email)
{
return self::findOne([‘seller_email’ => $seller_email]);
}
/**
-
@inheritDoc
*/
public function getId()
{
return $this->seller_user_id;
}
/**
-
@inheritDoc
*/
public function getAuthKey()
{
return $this->authkey;
}
/**
-
@inheritDoc
*/
public function validateAuthKey($authKey)
{
return $this->authkey === $authKey;
}
public function validatePassword($password)
{
return password_verify($password,$this->password);
} - {@inheritdoc}
}
and here is my login controller
Blockquote<?php
namespace app\controllers;
use app\models\SellerUser;
use Yii;
use yii\web\Controller;
class UserSellerController extends Controller
{
/**
* Lists all SellerUser models.
* @return mixed
*/
public function actionIndex()
{
echo “Test”;
}
public function actionRegister()
{
$model = new SellerUser();
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
// form inputs are valid, do something here
$model->seller_name = $_POST['SellerUser']['seller_name'];
$model->seller_email = $_POST['SellerUser']['seller_email'];
$model->seller_mobile = $_POST['SellerUser']['seller_mobile'];
$model->password = password_hash($_POST['SellerUser']['password'],PASSWORD_ARGON2I);
$model->authkey = md5(random_bytes(5));
if($model->save())
{
return $this->redirect(['site/login']);
}
}
}
return $this->render('register', [
'model' => $model,
]);
}`Preformatted text`
}
i can upload more file like register or web file right now i am working in the basic yii plz @samdark or any help
sorry for code formatting i don’t know how to upload code
