Add New Property In Model File Of A Active Record In Yii

I am new in Yii framework and have a question.

I have a table named ‘node’ which has these fields:

id


name


parent_id

parent_id contain id of parent of a node which exist in this table too.

I have created model,controller and view files using Gii interface. In view files id of parent is shown but I want to display parent name instead of its id .

I guess maybe I need to add a public property in model class of this table, so I would be access to it via ->parent_name in view files.

How can I do it ? what files should I change ?

create a relation with name "parentNode" and then you can use $model->parentNode->name; in your views

Thank you.

How can I involve it in controller to have it in views that user $dataProviders?

I mean how can I return it in ActiveDataProvider for example to have it in index and admin view files ?