Last active
February 13, 2018 00:43
-
-
Save sebazamorano/e8cdc4af7468722c83d5728327cf4623 to your computer and use it in GitHub Desktop.
Laravel Curso
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//documento | |
Schema::create('documento', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->integer('numero')->unsigned(); | |
$table->integer('tipo_documento_id')->unsigned(); | |
$table->integer('proveedor_id')->unsigned(); | |
$table->integer('user_id')->unsigned(); | |
$table->string('forma_pago'); | |
$table->integer('neto')->unsigned(); | |
$table->float('iva', 8, 2); | |
$table->float('total'); | |
$table->timestamps(); | |
$table->foreign('tipo_documento_id') | |
->references('id')->on('tipo_documento')->onDelete('cascade'); | |
$table->foreign('proveedor_id') | |
->references('id')->on('proveedor')->onDelete('cascade'); | |
$table->foreign('user_id') | |
->references('id')->on('users')->onDelete('cascade'); | |
}); | |
//producto | |
Schema::create('producto', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->string('nombre'); | |
$table->float('precio'); | |
$table->timestamps(); | |
}); | |
//Detalle Documento | |
Schema::create('detalle_documento', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->integer('documento_id'); | |
$table->integer('producto_id'); | |
$table->integer('cantidad')->unsigned(); | |
$table->float('precio'); | |
$table->timestamps(); | |
$table->foreign('documento_id')->references('id')->on('documento')->onDelete('cascade'); | |
$table->foreign('producto_id')->references('id')->on('producto')->onDelete('cascade'); | |
}); | |
Schema::create('categoria', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->string('nombre'); | |
$table->timestamps(); | |
}); | |
Schema::create('producto_categoria', function (Blueprint $table) { | |
$table->integer('producto_id'); | |
$table->integer('categoria_id'); | |
$table->foreign('producto_id') | |
->references('id')->on('producto')->onDelete('cascade'); | |
$table->foreign('categoria_id') | |
->references('id')->on('categoria')->onDelete('cascade'); | |
}); | |
//Proveedor | |
Schema::create('proveedor', function (Blueprint $table) { | |
$table->increments('id'); | |
$table->string('nombre'); | |
$table->string('rut', 100)->unique(); | |
$table->string('direccion'); | |
$table->string('email'); | |
$table->integer('telefono'); | |
$table->string('giro'); | |
$table->timestamps(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment