This Gist is for reduce appends item in laravel model which provide auto create attribute for dates to be formatted
Basic Append
protected $appends = [
..
..
'updated_at_formatted',
'created_at_formatted',
'post_created_time_formatted'
];
Then, need to create function for the updated_at_formatted
name getUpdatedAtFormattedAttribute()
Date Formatted Style
- No need to appends or create the attribute function. see Announcement.php
// which column to make it formatted<br>
protected $column_date = ['post_created_time', 'created_at', 'updated_at'];<br>
// how the date column is format<br>
protected $column_date_formatted = ['M d Y, H:i', 'd-m-Y h:i:s a', 'd-m-Y h:i:s a'];<br>
// all column will followed the same format<br>
// protected $column_date_formatted = 'M d Y, H:i';<br>