Reputation: 152
I am trying to avoid round-up for two variables (inf_lat and inf_long) as I need to use them on leaflet map. This is how I display them on my project which returns a whole number instead of a decimal. It doesn't seem to be a problem but the marker on the leaflet map is spotted on the wrong location.
Display page
<!-- Inf Lat Field -->
<div class="form-group">
{!! Form::label('inf_lat', 'Latitude:') !!}
{{ $infrastructure->inf_lat }}
</div>
<!-- Inf Long Field -->
<div class="form-group">
{!! Form::label('inf_long', 'Longtitude:') !!}
{{ $infrastructure->inf_long }}
</div>
DB Migration
$table->decimal('inf_lat', 9, 4);
$table->decimal('inf_long', 9, 4);
Upvotes: 0
Views: 282
Reputation: 152
Thanks guys, Solution provided below
<!-- Inf Lat Field -->
<div class="form-group">
{!! Form::label('inf_lat', 'Latitude:') !!}
{{ number_format ($infrastructure->inf_lat, 4) }}
</div>
<!-- Inf Long Field -->
<div class="form-group">
{!! Form::label('inf_long', 'Longtitude:') !!}
{{ number_format($infrastructure->inf_long, 4) }}
</div>
Model
'inf_lat' => 'double', // I changed it from integer
'inf_long' => 'double', // I changed it from integer
Upvotes: 0
Reputation: 47
Maybe you can try this
{{ number_format($infrastructure->inf_lat, 4, '', '.') }}
Upvotes: 1