code: public static function getNameById($id, $attributeName = 'name')
      {
          $model = static::loadModel($id);
          return empty($model[$attributeName]) === false ? $model[$attributeName] : \Yii::t('app', 'Unknown');
      }
docs: Get the record name by id.
  @param integer $id
  @param string $attributeName
  @return string