Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel mutators

class Video extends Model
{
    public function setDurationInMinutesAttribute($value)
    {
        $this->attributes['duration_in_seconds'] = $value * 60;
    }

    public function setDurationInHoursAttribute($value)
    {
        $this->attributes['duration_in_seconds'] = $value * 60 * 60;
    }
}

Source by laravel-news.com #
 
PREVIOUS NEXT
Tagged: #laravel #mutators
ADD COMMENT
Topic
Name
2+1 =