Skip to content

Instantly share code, notes, and snippets.

@evercode1
Created December 31, 2014 07:38
Show Gist options
  • Save evercode1/d8d588f4a8958594d4d3 to your computer and use it in GitHub Desktop.
Save evercode1/d8d588f4a8958594d4d3 to your computer and use it in GitHub Desktop.
User Status Relationship 5
/**
* 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