Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel How to include model attribute automatically

<?php

class User {

    protected $appends = ['avatar_url'];

    public function getAvatarUrlAttribute()
    {    
        return 'https://i.pravatar.cc/300?u=' . $this->email;
    }

}
 
PREVIOUS NEXT
Tagged: #laravel #How #include #model #attribute #automatically
ADD COMMENT
Topic
Name
3+6 =