Level 88
Nov 29, 2016
1
Level 1
How to set date mutator for pivot date fields
I have pivot table fields such as --start_date and end_date. --
--How to set these field as date fields ( mutator).. --
like protected dates = ['created_at', 'updated_at']
I try the following method. But it does not work. No impact when access the start_date and date_date fields
public function getStartDateAttribute($value) {
return Carbon::parse($value)->format('d-m-Y');
}
public function getEndDateAttribute($value) {
return Carbon::parse($value)->format('d-m-Y');
}
public function getPivotStartDateAttribute($value) {
return Carbon::parse($value)->format('d-m-Y');
}
public function getPivotEndDateAttribute($value) {
return Carbon::parse($value)->format('d-m-Y');
}
Please or to participate in this conversation.