feature/modelos-y-migraciones #3
|
@ -22,4 +22,12 @@ public function pedidos(): BelongsToMany
|
|||
{
|
||||
return $this->belongsToMany(Pedido::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Las caracteristicas que pertenecen al producto.
|
||||
*/
|
||||
public function caracteristicas(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Caracteristica::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?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_caracteristicas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('producto_id');
|
||||
$table->unsignedBigInteger('caracteristica_id');
|
||||
$table->timestamps();
|
||||
$table->foreign('producto_id')->references('id')->on('productos');
|
||||
$table->foreign('caracteristica_id')->references('id')->on('caracteristicas');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('productos_caracteristicas');
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue