Servicio.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "Servicio".
  6. *
  7. * @property string $id
  8. * @property string $factura
  9. * @property string $idTipo
  10. * @property string|null $descripcion
  11. * @property string|null $fechaServicio
  12. * @property string|null $idTaller
  13. * @property string|null $idVehiculo
  14. * @property string|null $creado
  15. * @property string|null $modificado
  16. * @property string|null $eliminado
  17. *
  18. * @property Taller $idTaller
  19. * @property Vehiculo $idVehiculo
  20. * @property TipoServicio $idTipo
  21. * @property ServicioElemento[] $servicioElementos
  22. */
  23. class Servicio extends ModeloBase
  24. {
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public static function tableName()
  29. {
  30. return 'Servicio';
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function rules()
  36. {
  37. return [
  38. [['id', 'factura'], 'required'],
  39. [['descripcion'], 'string'],
  40. [['fechaServicio', 'creado', 'modificado', 'eliminado'], 'safe'],
  41. [['id', 'idTaller', 'idVehiculo', 'idTipo' ], 'string', 'max' => 36],
  42. [['factura'], 'string', 'max' => 100],
  43. [['id'], 'unique'],
  44. [['idTaller'], 'exist', 'skipOnError' => true, 'targetClass' => Taller::class, 'targetAttribute' => ['idTaller' => 'id']],
  45. [['idVehiculo'], 'exist', 'skipOnError' => true, 'targetClass' => Vehiculo::class, 'targetAttribute' => ['idVehiculo' => 'id']],
  46. [['idTipo'], 'exist', 'skipOnError' => true, 'targetClass' => TipoServicio::class, 'targetAttribute' => ['idTipo' => 'id']],
  47. ];
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function attributeLabels()
  53. {
  54. return [
  55. 'id' => 'ID',
  56. 'factura' => 'Factura',
  57. 'descripcion' => 'Descripcion',
  58. 'fechaServicio' => 'Fecha Servicio',
  59. 'idTaller' => 'Id Taller',
  60. 'idVehiculo' => 'Id Vehiculo',
  61. 'idTipo'=>'Id Tipo Servicio',
  62. 'creado' => 'Creado',
  63. 'modificado' => 'Modificado',
  64. 'eliminado' => 'Eliminado',
  65. ];
  66. }
  67. /**
  68. * Gets query for [[IdTaller0]].
  69. *
  70. * @return \yii\db\ActiveQuery
  71. */
  72. public function getTaller()
  73. {
  74. return $this->hasOne(Taller::class, ['id' => 'idTaller']);
  75. }
  76. /**
  77. * Gets query for [[IdVehiculo0]].
  78. *
  79. * @return \yii\db\ActiveQuery
  80. */
  81. public function getVehiculo()
  82. {
  83. return $this->hasOne(Vehiculo::class, ['id' => 'idVehiculo']);
  84. }
  85. public function getTipoServicio()
  86. {
  87. return $this->hasOne(TipoServicio::class, ['id' => 'idTipo']);
  88. }
  89. /**
  90. * Gets query for [[ServicioElementos]].
  91. *
  92. * @return \yii\db\ActiveQuery
  93. */
  94. public function getServicioElemento()
  95. {
  96. return $this->hasMany(ServicioElemento::class, ['idServicio' => 'id']);
  97. }
  98. }