25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

66 lines
1.3 KiB

  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. use yii\db\Expression;
  5. /**
  6. * This is the model class for table "fx_user_area".
  7. *
  8. * @property integer $area_id
  9. * @property string $area_name
  10. */
  11. class FxUserArea extends \yii\db\ActiveRecord
  12. {
  13. /**
  14. * @inheritdoc
  15. */
  16. public static function tableName()
  17. {
  18. return 'fx_user_area';
  19. }
  20. /**
  21. * @inheritdoc
  22. */
  23. public function rules()
  24. {
  25. return [
  26. [['area_name'], 'required'],
  27. [['area_name'], 'string', 'max' => 100],
  28. ];
  29. }
  30. /**
  31. * @inheritdoc
  32. */
  33. public function attributeLabels()
  34. {
  35. return [
  36. 'area_id' => 'Area ID',
  37. 'area_name' => 'Area Name',
  38. ];
  39. }
  40. /**
  41. * Des:获取用户所属区域列表
  42. * Name: getUserAreaList
  43. * @param string $user_area
  44. * @return array
  45. * @author 倪宗锋
  46. */
  47. public function getUserAreaList($user_area = '')
  48. {
  49. $select = [
  50. 'is_bind' => empty($user_area) ? new Expression("0") : new Expression("if(area_id in ($user_area),1,0)"),
  51. 'area_id',
  52. 'area_name'
  53. ];
  54. $getList = self::find()->select($select)
  55. ->asArray()
  56. ->all();
  57. return $getList;
  58. }
  59. }