laravel修改返回数据集合的字段

public function index()
{
$users = User::all();
$users->map(function ($value) {
$value->name = 'MyName' . $value->name;
});
dd($users);
}

单独加入一个字段

protected $appends=['name_label'];

public function getNameLabelAttribute()
{
    return $this->prefix_name.$this->name;

}