Reputation: 104
My database includes a table named Quotations
. This table has a column named Cost
with a datatype decimal (10, 2). Values are saved/updated as per my expectation inside the column just like (25.75
, 4.35
, 10.38
etc).
Problem is that whenever I use {{ $quotation->cost }}
to display the information, all the decimals are printed as integers like (25
, 4
, 10
). But if I check it with {{ dd($quotation) }}
, it shows all the exact decimal values like (25.75
, 4.35
, 10.38
etc).
I shall appreciate it if someone points out the root cause of the problem.
Upvotes: 0
Views: 939
Reputation: 104
Problem solved. I thank everybody for your timely responses.
Before the solution, I actually was ignoring protected $casts = [ 'cost' => 'integer' ]
. Replacing integer
to float
resolved my issue.
Upvotes: 1
Reputation: 642
Use number_format function while displaying the decimal value
Upvotes: 0