Class LoginForm not found

I’m getting an error which says “Class ‘app\models\LoginForm’ not found” in SiteController.php

Model’s function which I’m getting the error


 public function actionLogin()

    {

        if (!Yii::$app->user->isGuest) {

            return $this->goHome();

        }


        $model = new LoginForm();

        if ($model->load(Yii::$app->request->post()) && $model->login()) {

            return $this->goBack();

        }

        return $this->render('login', [

            'model' => $model,

        ]);

    }

In this line:


$model = new LoginForm();

I don’t know what happened since I didn’t changed any code in SiteController I still have this:

use Yii;

use yii\filters\AccessControl;

use yii\web\Controller;

use yii\web\Response;

use yii\filters\VerbFilter;

use app\models\LoginForm;

use app\models\ContactForm;

Which file is your model in? And does it declare a namespace?

What file?

Edit:

I solved the problem, and it’s weird.

The LoginForm.php was missing and I checked out my Recycle Bin and I found out that it was deleted. I don’t why but what a silly mistake.