Estado.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /**
  20. * {@inheritdoc}
  21. */
  22. public static function tableName()
  23. {
  24. return 'Estado';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['id'], 'required'],
  33. [['creado', 'modificado', 'eliminado'], 'safe'],
  34. [['id'], 'string', 'max' => 36],
  35. [['nombre'], 'string', 'max' => 100],
  36. [['abreviacion'], 'string', 'max' => 16],
  37. [['id'], 'unique'],
  38. ];
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'ID',
  47. 'nombre' => 'Nombre',
  48. 'abreviacion' => 'Abreviacion',
  49. 'creado' => 'Creado',
  50. 'modificado' => 'Modificado',
  51. 'eliminado' => 'Eliminado',
  52. ];
  53. }
  54. /**
  55. * Gets query for [[Municipios]].
  56. *
  57. * @return \yii\db\ActiveQuery
  58. */
  59. public function getMunicipios()
  60. {
  61. return $this->hasMany(Municipio::class, ['idEstado' => 'id']);
  62. }
  63. }