definicion de pedido y migracion de productos_pedidos

This commit is contained in:
Alejandro Tasistro 2024-03-11 19:55:35 -03:00
parent 983b63897d
commit 1129a9e11b
2 changed files with 39 additions and 0 deletions

View File

@ -24,4 +24,11 @@ public function barrio(): BelongsTo
return $this->belongsTo(Barrio::class); return $this->belongsTo(Barrio::class);
} }
/**
* Los productos que pertenecen al pedido.
*/
public function productos(): BelongsToMany
{
return $this->belongsToMany(Producto::class);
}
} }

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('productos_pedidos', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('pedido_id');
$table->unsignedBigInteger('producto_id');
$table->unsignedInteger('ammount');
$table->timestamps();
$table->foreign('pedido_id')->references('id')->on('pedidos');
$table->foreign('producto_id')->references('id')->on('productos');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('productos_pedidos');
}
};