From 7ebeccd2694350d653d50a0efe77ccf4e6593cd6 Mon Sep 17 00:00:00 2001 From: nat Date: Thu, 30 Dec 2021 13:12:14 -0300 Subject: [PATCH] Modelos y tablas base --- .env.example | 2 +- app/Admin.php | 10 +++++ app/GrupoDeCompra.php | 13 ++++++ app/Http/Controllers/AdminController.php | 10 +++++ app/Producto.php | 22 ++++++++++ app/Proveedor.php | 17 ++++++++ app/Subpedido.php | 25 +++++++++++ ...3_165235_create_grupos_de_compra_table.php | 38 ++++++++++++++++ ..._09_23_173149_create_proveedores_table.php | 39 +++++++++++++++++ ...20_09_23_173620_create_productos_table.php | 41 ++++++++++++++++++ ...0_09_23_180334_create_subpedidos_table.php | 43 +++++++++++++++++++ .../2021_12_30_153540_create_admins_table.php | 35 +++++++++++++++ 12 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 app/Admin.php create mode 100644 app/GrupoDeCompra.php create mode 100644 app/Http/Controllers/AdminController.php create mode 100644 app/Producto.php create mode 100644 app/Proveedor.php create mode 100644 app/Subpedido.php create mode 100644 database/migrations/2020_09_23_165235_create_grupos_de_compra_table.php create mode 100644 database/migrations/2020_09_23_173149_create_proveedores_table.php create mode 100644 database/migrations/2020_09_23_173620_create_productos_table.php create mode 100644 database/migrations/2020_09_23_180334_create_subpedidos_table.php create mode 100644 database/migrations/2021_12_30_153540_create_admins_table.php diff --git a/.env.example b/.env.example index fe75e5a..e478abb 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -APP_NAME="Compras MPS" +APP_NAME="Backend de Pedidos MPS" APP_ENV=local APP_KEY= APP_DEBUG=true diff --git a/app/Admin.php b/app/Admin.php new file mode 100644 index 0000000..9745b32 --- /dev/null +++ b/app/Admin.php @@ -0,0 +1,10 @@ +belongsToMany('App\Subpedido','productos_subpedidos')->withPivot(["cantidad"]); + } + + public function proveedor() + { + return $this->belongsTo('App\Proveedor'); + } + +} diff --git a/app/Proveedor.php b/app/Proveedor.php new file mode 100644 index 0000000..20af175 --- /dev/null +++ b/app/Proveedor.php @@ -0,0 +1,17 @@ +hasMany('App\Producto'); + } +} diff --git a/app/Subpedido.php b/app/Subpedido.php new file mode 100644 index 0000000..61d92c8 --- /dev/null +++ b/app/Subpedido.php @@ -0,0 +1,25 @@ +belongsToMany('App\Producto','pedidos_productos')->withPivot(["cantidad"]); + } + + public function grupoDeCompra() + { + return $this->belongsTo('App\GrupoDeCompra'); + } + +} diff --git a/database/migrations/2020_09_23_165235_create_grupos_de_compra_table.php b/database/migrations/2020_09_23_165235_create_grupos_de_compra_table.php new file mode 100644 index 0000000..c14c05d --- /dev/null +++ b/database/migrations/2020_09_23_165235_create_grupos_de_compra_table.php @@ -0,0 +1,38 @@ +id(); + $table->string('nombre'); + $table->string('region'); + $table->double('cantidad_de_nucleos', 3, 0)->nullable(); + $table->string('telefono')->nullable(); + $table->string('correo')->nullable(); + $table->string('referente_finanzas')->nullable(); + $table->string('contraseƱa'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('grupos_de_compra'); + } +} diff --git a/database/migrations/2020_09_23_173149_create_proveedores_table.php b/database/migrations/2020_09_23_173149_create_proveedores_table.php new file mode 100644 index 0000000..fcc0ad7 --- /dev/null +++ b/database/migrations/2020_09_23_173149_create_proveedores_table.php @@ -0,0 +1,39 @@ +id(); + $table->string('nombre'); + $table->string('direccion')->nullable(); + $table->string('telefono')->nullable(); + $table->string('correo')->nullable(); + $table->boolean('economia_solidaria')->nullable(); + $table->boolean('nacional')->nullable(); + $table->text('detalles_de_pago')->nullable(); + $table->text('comentario')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('proveedores'); + } +} diff --git a/database/migrations/2020_09_23_173620_create_productos_table.php b/database/migrations/2020_09_23_173620_create_productos_table.php new file mode 100644 index 0000000..420a077 --- /dev/null +++ b/database/migrations/2020_09_23_173620_create_productos_table.php @@ -0,0 +1,41 @@ +id(); + $table->string('nombre'); + $table->double('precio', 10, 2); + $table->string('categoria')->nullable(); + $table->integer('presentacion')->default(1); + $table->integer('stock')->default(0); + $table->foreignId('proveedor_id')->nullable(); + $table->foreignId('imagen_id')->nullable(); + $table->text('descripcion')->nullable(); + $table->boolean('apto_veganxs')->nullable(); + $table->boolean('apto_caliacxs')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('productos'); + } +} diff --git a/database/migrations/2020_09_23_180334_create_subpedidos_table.php b/database/migrations/2020_09_23_180334_create_subpedidos_table.php new file mode 100644 index 0000000..f0808d5 --- /dev/null +++ b/database/migrations/2020_09_23_180334_create_subpedidos_table.php @@ -0,0 +1,43 @@ +id(); + $table->string('nombre'); + $table->foreignId('grupo_de_compra_id'); + $table->boolean('aprobado')->nullable(); + $table->timestamps(); + }); + + Schema::create('producto_subpedido', function (Blueprint $table) { + $table->id(); + $table->foreignId('subpedido_id'); + $table->foreignId('producto_id'); + $table->integer('cantidad')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('producto_subpedido'); + Schema::dropIfExists('subpedidos'); + } +} diff --git a/database/migrations/2021_12_30_153540_create_admins_table.php b/database/migrations/2021_12_30_153540_create_admins_table.php new file mode 100644 index 0000000..328936b --- /dev/null +++ b/database/migrations/2021_12_30_153540_create_admins_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('nombre'); + $table->foreignId('grupo_de_compra_id'); + $table->string('email'); + $table->string('contrasena'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('admins'); + } +}