Send calculated Eloquent fields

Return calculated availability field:

class Book extends Model
{
        protected $fillable = ['isbn','title'];

        protected $appends = array('availability');

        public function getAvailabilityAttribute()
        {
                return 123;
        }

}

Do something with an real field too:

class Product extends Model
{
        protected $casts = ['price' => 'integer'];

        protected $appends = ['price_in_pounds'];

        public function getPriceInPounds()
        {
                if ($this->price == 0) return $this->price;
                return $this->price / 100;
        }

}