mercredi 29 janvier 2020

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 ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire