mercredi 15 février 2017

Laravel 5 how to modify default Date accessors?

I have a code like this:

public function getUpdatedAtAttribute($value) {
    setlocale(LC_TIME, config('app.locale'));
    return Carbon::parse($value)->formatLocalized(__('DateFormat'));
}

I want to run this accessor for each field specified in $dates array instead of manually specifying it for each date field in each model, just like default Carbon instance convertion works. How could I do this? And is there better ways of specifying default locale-dependant date format for Carbon?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l71JUl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire