CompraProducto.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "CompraProducto".
  6. *
  7. * @property string $id
  8. * @property string|null $idCompra
  9. * @property string|null $idUnidadMedida
  10. * @property string|null $idPartida
  11. * @property string|null $producto
  12. * @property string|null $cantidad
  13. * @property float|null $precio
  14. * @property string|null $descripcion
  15. * @property string|null $creado
  16. * @property string|null $modificado
  17. * @property string|null $eliminado
  18. *
  19. * @property Compra $idCompra0
  20. * @property Partida $idPartida0
  21. * @property UnidadMedida $idUnidadMedida0
  22. */
  23. class CompraProducto extends \yii\db\ActiveRecord
  24. {
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public static function tableName()
  29. {
  30. return 'CompraProducto';
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function rules()
  36. {
  37. return [
  38. [['id'], 'required'],
  39. [['precio'], 'number'],
  40. [['descripcion'], 'string'],
  41. [['creado', 'modificado', 'eliminado'], 'safe'],
  42. [['id', 'idCompra', 'idUnidadMedida', 'idPartida'], 'string', 'max' => 36],
  43. [['producto', 'cantidad'], 'string', 'max' => 255],
  44. [['id'], 'unique'],
  45. [['idCompra'], 'exist', 'skipOnError' => true, 'targetClass' => Compra::class, 'targetAttribute' => ['idCompra' => 'id']],
  46. [['idPartida'], 'exist', 'skipOnError' => true, 'targetClass' => Partida::class, 'targetAttribute' => ['idPartida' => 'id']],
  47. [['idUnidadMedida'], 'exist', 'skipOnError' => true, 'targetClass' => UnidadMedida::class, 'targetAttribute' => ['idUnidadMedida' => 'id']],
  48. ];
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'id' => 'ID',
  57. 'idCompra' => 'Id Compra',
  58. 'idUnidadMedida' => 'Id Unidad Medida',
  59. 'idPartida' => 'Id Partida',
  60. 'producto' => 'Producto',
  61. 'cantidad' => 'Cantidad',
  62. 'precio' => 'Precio',
  63. 'descripcion' => 'Descripcion',
  64. 'creado' => 'Creado',
  65. 'modificado' => 'Modificado',
  66. 'eliminado' => 'Eliminado',
  67. ];
  68. }
  69. public function getCompra()
  70. {
  71. return $this->hasOne(Compra::class, ['id' => 'idCompra']);
  72. }
  73. public function getPartida()
  74. {
  75. return $this->hasOne(Partida::class, ['id' => 'idPartida']);
  76. }
  77. public function getUnidadMedida()
  78. {
  79. return $this->hasOne(UnidadMedida::class, ['id' => 'idUnidadMedida']);
  80. }
  81. }