O'Reilly logo

Yii Rapid Application Development Hotshot by James R. Hamilton III, Lauren J. O'Meara

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Roles to User Management

As you can see, the interface provided by the srbac extension is very powerful and convenient. It is great for adding new roles, tasks, and operations. However, when we add new users to the system, it would be convenient to assign the users, roles on the spot.

Engage Thrusters

  1. First, add the relationship to the assignment object in the User model (ch4 | Source Files | protected | models | User.php).

    i. Add a comment at the top of the file listing the new model variable in the model relations section as follows:

    * The following are the available model relations:
     * @property Person $person
     * @property Assignments[] $assignments
    

    ii. Add an entry for assignments to the relations array as follows:

     return array( 'person' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required