我有一个User.php模型.
public function getFullNameAttribute()
{
if($this->first_name && $this->last_name) {
return $this->first_name . ' ' . $this->last_name;
} else {
return $this->name;
}
}
在Blade 文件中,如果我们想获得它,我是这样写的.
{{ $user->full_name }}
但我不知道在AJAX中怎么做.我编写了以下代码,结果显示为undefined
.
<strong class="f20 mb-1">`+user.full_name+`</strong>