Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel custom attributes

<?php
...

class Movie extends Model
{

    protected $appends = ['cover'];

    //define accessor
    public function getCoverAttribute()
    {
        return json_decode($this->InJson)->cover;
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #custom #attributes
ADD COMMENT
Topic
Name
5+2 =