Obra.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "Obra".
  6. *
  7. * @property string $id
  8. * @property string $nombre
  9. * @property string|null $fechaInicio
  10. * @property string|null $fechaFinal
  11. * @property string|null $descripcion
  12. * @property string|null $creado
  13. * @property string|null $modificado
  14. * @property string|null $eliminado
  15. * @property string|null $clave
  16. *
  17. * @property HerramientaObra[] $herramientaObras
  18. * @property ObraEmpleado[] $obraEmpleados
  19. * @property ObraHerramienta[] $obraHerramientas
  20. */
  21. class Obra extends ModeloBase
  22. {
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public static function tableName()
  27. {
  28. return 'Obra';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules()
  34. {
  35. return [
  36. [['id', 'nombre', 'fechaInicio','fechaFinal'], 'required'],
  37. [['fechaInicio','fechaFinal','creado', 'modificado', 'eliminado'], 'safe'],
  38. [['id'], 'string', 'max' => 36],
  39. [['nombre', 'descripcion','clave'], 'string', 'max' => 100],
  40. [['id'], 'unique'],
  41. ];
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function attributeLabels()
  47. {
  48. return [
  49. 'id' => 'ID',
  50. 'clave' => 'Clave',
  51. 'nombre' => 'Nombre',
  52. 'fechaInicio' => 'Fecha Inicio',
  53. 'fechaFinal' => 'Fecha Final',
  54. 'descripcion' => 'Descripcion',
  55. 'creado' => 'Creado',
  56. 'modificado' => 'Modificado',
  57. 'eliminado' => 'Eliminado',
  58. ];
  59. }
  60. public function getHerramientaObras()
  61. {
  62. return $this->hasMany(HerramientaObra::class, ['idObra' => 'id']);
  63. }
  64. public function getObraEmpleado()
  65. {
  66. return $this->hasMany(ObraEmpleado::class, ['idObra' => 'id']);
  67. }
  68. public function getObraHerramienta()
  69. {
  70. return $this->hasMany(ObraHerramienta::class, ['idObra' => 'id']);
  71. }
  72. }