Issue
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.
Solution
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.
Answered By - Ahmed Naveed Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.