How can i write accessor methods for created_at or updated_at in Laravel 5.8?

I made two accessors like below code, but while fetching it is not showing what is being passed in accessors for created_at & updated.


/**
* This will change date according to timezone.
* @param String path
*/
public function getCreatedAtAttribute($value)
{
return $this->changeDateFormUTCtoLocal($value);
}

/**
* This will change date according to timezone.
* @param String path
*/
public function getUpdatedAtAttribute($value)
{
return $this->changeDateFormUTCtoLocal($value);
}

But this is not working. While other accessors are working which are following camelCase convention. Personally i assume it as an case issue. I think laravel assumes attributes as camelCase. What can be the solution ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3aOdIzz
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time