Estado.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. use yii\base\Model;
  5. /**
  6. * This is the model class for table "Estado".
  7. *
  8. * @property string $id
  9. * @property string|null $nombre
  10. * @property string|null $abreviacion
  11. * @property string|null $creado
  12. * @property string|null $modificado
  13. * @property string|null $eliminado
  14. *
  15. * @property Municipio[] $municipios
  16. */
  17. class Estado extends ModeloBase {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName() {
  22. return 'Estado';
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function rules() {
  28. return [
  29. [['id'], 'required'],
  30. /* [['clave'], 'integer'], */
  31. [['creado', 'modificado', 'eliminado'], 'safe'],
  32. [['id', 'pais'], 'string', 'max' => 36],
  33. [['nombre'], 'string', 'max' => 100],
  34. [['abreviacion'], 'string', 'max' => 16],
  35. [['id'], 'unique'],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels() {
  42. return [
  43. 'id' => 'ID',
  44. 'nombre' => 'Nombre',
  45. 'abreviacion' => 'Abreviacion',
  46. 'creado' => 'Creado',
  47. 'modificado' => 'Modificado',
  48. 'eliminado' => 'Eliminado',
  49. /* 'clave' => 'Clave', */
  50. /* 'pais' => 'Pais', */
  51. ];
  52. }
  53. /**
  54. * Gets query for [[Municipios]].
  55. *
  56. * @return \yii\db\ActiveQuery
  57. */
  58. public function getMunicipios() {
  59. return $this->hasMany(Municipio::class, ['idEstado' => 'id']);
  60. }
  61. }