'casts property is not working to change date format
I am trying to change date format while fetching data in this way
protected $casts = [
'due_date' => 'date:d-m-Y',
];
Blade
{{$ticket->due_date}}
It is showing is like
2022-03-13
Solution 1:[1]
Casts are for json serialization (json_encode($ticket)). To get the format you want in blade, use Carbon's format method.
{{ $ticket->due_date->format('d-m-Y') }}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | IGP |
