Created
December 31, 2014 07:14
-
-
Save evercode1/22a305bdf1e85a4967df to your computer and use it in GitHub Desktop.
User Relationships to Role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get role relationship | |
* | |
*/ | |
public function getRole() | |
{ | |
return $this->hasOne(Role::className(), ['role_value' => 'role_id']); | |
} | |
/** | |
* get role name | |
* | |
*/ | |
public function getRoleName() | |
{ | |
return $this->role ? $this->role->role_name : '- no role -'; | |
} | |
/** | |
* get list of roles for dropdown | |
*/ | |
public static function getRoleList() | |
{ | |
$droptions = Role::find()->asArray()->all(); | |
return ArrayHelper::map($droptions, 'role_value', 'role_name'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment