Servicio.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 $idTaller0
  19. * @property Vehiculo $idVehiculo0
  20. * @property TipoServicio $idTipo0
  21. * @property ServicioElemento[] $servicioElementos
  22. * @property ServicioTipoServicio[] $servicioTipoServicios
  23. */
  24. class Servicio extends ModeloBase
  25. {
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public static function tableName()
  30. {
  31. return 'Servicio';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function rules()
  37. {
  38. return [
  39. [['id', 'factura'], 'required'],
  40. [['descripcion'], 'string'],
  41. [['fechaServicio', 'creado', 'modificado', 'eliminado'], 'safe'],
  42. [['id', 'idTaller', 'idVehiculo', 'idTipo' ], 'string', 'max' => 36],
  43. [['factura'], 'string', 'max' => 100],
  44. [['id'], 'unique'],
  45. [['idTaller'], 'exist', 'skipOnError' => true, 'targetClass' => Taller::class, 'targetAttribute' => ['idTaller' => 'id']],
  46. [['idVehiculo'], 'exist', 'skipOnError' => true, 'targetClass' => Vehiculo::class, 'targetAttribute' => ['idVehiculo' => 'id']],
  47. [['idTipo'], 'exist', 'skipOnError' => true, 'targetClass' => TipoServicio::class, 'targetAttribute' => ['idTipo' => 'id']],
  48. ];
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'id' => 'ID',
  57. 'factura' => 'Factura',
  58. 'descripcion' => 'Descripcion',
  59. 'fechaServicio' => 'Fecha Servicio',
  60. 'idTaller' => 'Id Taller',
  61. 'idVehiculo' => 'Id Vehiculo',
  62. 'idTipo' => 'Id Tipo',
  63. 'creado' => 'Creado',
  64. 'modificado' => 'Modificado',
  65. 'eliminado' => 'Eliminado',
  66. ];
  67. }
  68. /**
  69. * Gets query for [[IdTaller0]].
  70. *
  71. * @return \yii\db\ActiveQuery
  72. */
  73. public function getTaller()
  74. {
  75. return $this->hasOne(Taller::class, ['id' => 'idTaller']);
  76. }
  77. public function getVehiculo()
  78. {
  79. return $this->hasOne(Vehiculo::class, ['id' => 'idVehiculo']);
  80. }
  81. public function getServicioElemento()
  82. {
  83. return $this->hasMany(ServicioElemento::class, ['idServicio' => 'id']);
  84. }
  85. public function getTipoServicio()
  86. {
  87. return $this->hasMany(ServicioTipoServicio::class, ['idServicio' => 'id']);
  88. }
  89. }