diff --git a/app/Models/Categoria.php b/app/Models/Categoria.php new file mode 100644 index 0000000..66993d1 --- /dev/null +++ b/app/Models/Categoria.php @@ -0,0 +1,26 @@ + + */ + protected $fillable = [ + 'name', + ]; + + /** + * Los productos que pertenecen a la categoría. + */ + public function productos(): HasMany + { + return $this->hasMany(Producto::class); + } +} diff --git a/database/migrations/2024_03_12_195353_create_categorias_table.php b/database/migrations/2024_03_12_195353_create_categorias_table.php new file mode 100644 index 0000000..f67f14c --- /dev/null +++ b/database/migrations/2024_03_12_195353_create_categorias_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name', 100); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('categorias'); + } +};