Created
December 31, 2014 07:38
-
-
Save evercode1/d8d588f4a8958594d4d3 to your computer and use it in GitHub Desktop.
User Status Relationship 5
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 status relation | |
* | |
*/ | |
public function getStatus() | |
{ | |
return $this->hasOne(Status::className(), ['status_value' => 'status_id']); | |
} | |
/** | |
* * get status name | |
* | |
*/ | |
public function getStatusName() | |
{ | |
return $this->status ? $this->status->status_name : '- no status -'; | |
} | |
/** | |
* get list of statuses for dropdown | |
*/ | |
public static function getStatusList() | |
{ | |
$droptions = Status::find()->asArray()->all(); | |
return ArrayHelper::map($droptions, 'status_value', 'status_name'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment