diff --git a/app/Filament/Resources/ProductoResource.php b/app/Filament/Resources/ProductoResource.php index 600cf7b..b9717b2 100644 --- a/app/Filament/Resources/ProductoResource.php +++ b/app/Filament/Resources/ProductoResource.php @@ -59,7 +59,9 @@ class ProductoResource extends Resource ->image() ->directory(directory: 'productos') ->maxSize(10240) - ->acceptedFileTypes(['image/jpeg', 'image/png', 'image/gif', 'image/webp']), + ->acceptedFileTypes(['image/jpeg', 'image/png', 'image/gif', 'image/webp']) + ->nullable() + ->helperText('Opcional'), Forms\Components\Textarea::make('descripcion') ->columnSpanFull() ->required() diff --git a/app/Models/Producto.php b/app/Models/Producto.php index 6e57fc6..10e8b24 100644 --- a/app/Models/Producto.php +++ b/app/Models/Producto.php @@ -43,6 +43,13 @@ class Producto extends Model 'estado' => 'boolean', ]; + /** + * Valores por defecto para atributos del modelo + */ + protected $attributes = [ + 'imagen' => '', + ]; + public function variants(): HasMany { return $this->hasMany(ProductVariant::class); diff --git a/database/migrations/2026_01_21_000000_make_imagen_nullable_in_productos_table.php b/database/migrations/2026_01_21_000000_make_imagen_nullable_in_productos_table.php new file mode 100644 index 0000000..0e4ef86 --- /dev/null +++ b/database/migrations/2026_01_21_000000_make_imagen_nullable_in_productos_table.php @@ -0,0 +1,30 @@ +string('imagen')->nullable()->default('')->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('productos', function (Blueprint $table) { + $table->string('imagen')->nullable(false)->default(null)->change(); + }); + } +};