I have a web made in laravel, livewire and I need to hide decimals in variable: 'valor' => $countPoblacion->poblacion] since it is currently showing decimals in all values.
class ConteoPoblacion extends Conteo
{
protected function cargarDatos($args = null)
{
if ($this->tieneArgumento('idMunicipio', $args))
{
$countPoblacion = Distrito::select(
DB::raw('SUM(poblacion) as poblacion'),
DB::raw('SUM(km2) as km2'),
)
->where('id', '=', $args['idMunicipio'])
->first();
return [
['nombre' => 'poblacion', 'valor' => $countPoblacion->poblacion],
['nombre' => 'densidad (hab/km2)', 'valor' => $countPoblacion->poblacion / $countPoblacion->km2],
['nombre' => 'superficie en km2', 'valor' => $countPoblacion->km2],
];
} else if ($this->tieneArgumento('idSeccion', $args))
{
$countPoblacion = Distrito::select(
DB::raw('SUM(poblacion) as poblacion'),
DB::raw('SUM(km2) as km2'),
)
->where('seccion_id', '=', $args['idSeccion'])
->first();
return [
['nombre' => 'poblacion', 'valor' => $countPoblacion->poblacion],
['nombre' => 'densidad (hab/km2)', 'valor' => $countPoblacion->poblacion / $countPoblacion->km2],
['nombre' => 'superficie en km2', 'valor' => $countPoblacion->km2],
];
}
}
}
Did you try rounding the numbers? Using any of these functions
round()
floor()
or
ceil()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.