'decimal:2', 'costo_por_metro' => 'decimal:2', ]; public function proveedor() { return $this->belongsTo(Proveedor::class); } public function ordenesProduccion() { return $this->hasMany(OrdenProduccion::class); } protected static function booted() { static::saving(function ($tela) { // Protección temporal: si la columna en la BD aún es integer, convertir a entero try { $type = \Illuminate\Support\Facades\Schema::getColumnType('telas', 'costo_por_metro'); if ($type === 'integer') { $tela->costo_por_metro = (int) round($tela->costo_por_metro ?? 0); } $typeVal = \Illuminate\Support\Facades\Schema::getColumnType('telas', 'valor_total'); if ($typeVal === 'integer') { $tela->valor_total = (int) round($tela->valor_total ?? 0); } } catch (\Exception $e) { // Ignorar si no se puede determinar el tipo de columna (por ejemplo en pruebas antes de migraciones) } }); } }