Incidente.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 $fechaIncidente
  10. * @property string|null $idObra
  11. * @property string|null $descripcion
  12. * @property string|null $creado
  13. * @property string|null $modificado
  14. * @property string|null $eliminado
  15. *
  16. * @property IncidenteEmpleado[] $incidenteEmpleado
  17. */
  18. class Incidente extends ModeloBase
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return 'Incidente';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['id', 'nombre', 'idObra'], 'required'],
  34. [['fechaIncidente','creado', 'modificado', 'eliminado'], 'safe'],
  35. [['id', 'idObra'], 'string', 'max' => 36],
  36. [['nombre', 'descripcion'], 'string', 'max' => 100],
  37. [['id'], 'unique'],
  38. [['idObra'], 'exist', 'skipOnError' => true, 'targetClass' => Obra::class, 'targetAttribute' => ['idObra' => 'id']],
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels()
  45. {
  46. return [
  47. 'id' => 'ID',
  48. 'nombre' => 'Nombre',
  49. 'fechaIncidente' => 'Fecha Incidente',
  50. 'idObra' => 'ID Obra',
  51. 'descripcion' => 'Descripcion',
  52. 'creado' => 'Creado',
  53. 'modificado' => 'Modificado',
  54. 'eliminado' => 'Eliminado',
  55. ];
  56. }
  57. public function getIncidenteEmpleado()
  58. {
  59. return $this->hasMany(IncidenteEmpleado::class, ['idIncidente' => 'id']);
  60. }
  61. public function getObra()
  62. {
  63. return $this->hasOne(Obra::class, ['id' => 'idObra']);
  64. }
  65. }