| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 | <?phpnamespace Tests\Models;use Illuminate\Database\Eloquent\Model;class User extends Model{    protected $table = 'test_users';    protected $appends = ['full_name', 'position'];    public function profile()    {        return $this->hasOne(Profile::class, 'user_id');    }    public function user_profile()    {        return $this->hasOne(Profile::class, 'user_id');    }    public function userProfile()    {        return $this->hasOne(Profile::class, 'user_id');    }    public function getFullNameAttribute()    {        if (! $this->profile) {            return;        }        return "{$this->profile['first_name']} {$this->profile['last_name']}";    }    public function getPositionAttribute()    {        if (! $this->profile) {            return;        }        return "{$this->profile->latitude} {$this->profile->longitude}";    }    public function tags()    {        return $this->belongsToMany(Tag::class, 'test_user_tags', 'user_id', 'tag_id');    }}
 |