feature/modelos-y-migraciones #3

Merged
rho merged 28 commits from feature/modelos-y-migraciones into master 2024-03-14 16:34:44 -03:00
2 changed files with 36 additions and 0 deletions
Showing only changes of commit 2e62fcb865 - Show all commits

View File

@ -7,6 +7,14 @@
class Producto extends Model
{
/**
* La categoría a la que pertenece el producto.
*/
public function categoria(): BelongsTo
{
return $this->belongsTo(Categoria::class);
}
/**
* Los pedidos que tienen al producto.
*/

View File

@ -0,0 +1,28 @@
<?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::table('productos', function (Blueprint $table) {
$table->unsignedBigInteger('categoria_id')->after('id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('productos', function (Blueprint $table) {
$table->dropColumn('categoria_id');
});
}
};