S
S
sergeev_ev2018-08-07 23:29:03
Yii
sergeev_ev, 2018-08-07 23:29:03

Yii2: What are the differences between User class extensions?

Good time friends.
Well, as usual, a lamer question for the amusement of the public.
So: I
started learning Yii2, in particular registration on the site.
After installing the framework, the beginning of the User class is like this:
class User extends \yii\base\BaseObject implements \yii\web\IdentityInterface
The teacher has this beginning:
class User extends ActiveRecord implements IdentityInterface
In the first scenario, the scenario is not defined by PhpStorm and an error appears like:
Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: app\models\User::scenario
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dave Hornigan, 2018-08-08
@sergeev_ev

Your class works with the base object, and the teacher's class with the database
In the basic application, a class like yours is immediately created, and the same as your teacher has by default is present in the advanced application in common / models.

R
Raccoon, 2018-08-08
@antonov22

scenario is a property of the yii\base\Model class, from which ActiveRecord is inherited. The basic template assumes that user data is stored in the users property of the User model, which is of course not convenient if users can be added in any way (via the admin panel or registration on the site). Therefore, they almost always inherit from ActiveRecord, no matter basic or advanced.
https://yiiframework.com.ua/ru/doc/guide/2/securit...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question