UserImmigrant.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace common\models;
  3. /**
  4. * This is the model class for table "{{%USER_IMMIGRANT}}".
  5. *
  6. * @property string ID
  7. * @property string user_id 用户ID
  8. * @property string before_country_id 移民前国家ID
  9. * @property string after_country_id 移民后国家ID
  10. * @property int period_num 期数
  11. * @property int created_at 创建时间
  12. * @property string created_by 创建人
  13. */
  14. class UserImmigrant extends \common\components\ActiveRecord
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public static function tableName()
  20. {
  21. return '{{%USER_IMMIGRANT}}';
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['user_id', 'before_country_id', 'after_country_id', 'period_num'], 'required'],
  30. [['period_num'], 'number'],
  31. ];
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function attributeLabels()
  37. {
  38. return [
  39. 'ID' => 'ID',
  40. 'user_id' => '用户ID',
  41. 'before_country_id' => '移民前国家ID',
  42. 'after_country_id' => '移民后国家ID',
  43. 'period_num' => '期数',
  44. 'created_at' => '创建时间',
  45. 'created_by' => '创建人',
  46. ];
  47. }
  48. public function beforeCountry()
  49. {
  50. return $this->hasOne(Countries::class, ['ID' => 'before_country_id']);
  51. }
  52. public function afterCountry()
  53. {
  54. return $this->hasOne(Countries::class, ['ID' => 'after_country_id']);
  55. }
  56. public function member()
  57. {
  58. return $this->hasOne(User::class, ['ID' => 'user_id']);
  59. }
  60. public function creater()
  61. {
  62. return $this->hasOne(User::class, ['ID' => 'created_by']);
  63. }
  64. }