Modelos y tablas base

This commit is contained in:
nat 2021-12-30 13:12:14 -03:00
parent 1b84371a85
commit 7ebeccd269
12 changed files with 294 additions and 1 deletions

View File

@ -1,4 +1,4 @@
APP_NAME="Compras MPS" APP_NAME="Backend de Pedidos MPS"
APP_ENV=local APP_ENV=local
APP_KEY= APP_KEY=
APP_DEBUG=true APP_DEBUG=true

10
app/Admin.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Admin extends Model
{
//
}

13
app/GrupoDeCompra.php Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class GrupoDeCompra extends Model
{
public $timestamps = false;
protected $fillable = [ "nombre","region","telefono","correo","referente_finanzas","cantidad_de_nucleos"];
protected $table = 'grupos_de_compra';
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AdminController extends Controller
{
//
}

22
app/Producto.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Producto extends Model
{
public $timestamps = false;
protected $fillable = [ "nombre", "precio", "presentacion", "stock", "categoria" ];
public function subpedidos()
{
return $this->belongsToMany('App\Subpedido','productos_subpedidos')->withPivot(["cantidad"]);
}
public function proveedor()
{
return $this->belongsTo('App\Proveedor');
}
}

17
app/Proveedor.php Normal file
View File

@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Proveedor extends Model
{
public $timestamps = false;
protected $fillable = [ "nombre","direccion","telefono","correo","comentario" ];
protected $table = 'proveedores';
public function productos()
{
return $this->hasMany('App\Producto');
}
}

25
app/Subpedido.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App;
use League\Csv\Reader;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Log;
class Subpedido extends Model
{
public $timestamps = false;
protected $fillable = ['grupo_de_compra_id', 'aprobado', 'nombre'];
public function productos()
{
return $this->belongsToMany('App\Producto','pedidos_productos')->withPivot(["cantidad"]);
}
public function grupoDeCompra()
{
return $this->belongsTo('App\GrupoDeCompra');
}
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateGruposDeCompraTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('grupos_de_compra', function (Blueprint $table) {
$table->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');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProveedoresTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('proveedores', function (Blueprint $table) {
$table->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');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProductosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('productos', function (Blueprint $table) {
$table->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');
}
}

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSubpedidosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subpedidos', function (Blueprint $table) {
$table->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');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAdminsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('admins', function (Blueprint $table) {
$table->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');
}
}