laravel getNameAttribute不适用于搜索

我有帐户模型 而且我里面有这个方法..

public function getNameAttribute()
{
    if(\App::getLocale() == 'en')
        return $this->attributes['foreign_name'];
    else
        return $this->attributes['name'];
}

in the index page its working if the locale is en the name will be the foreign_name like this picture enter image description here but i have search method and this is the code

public static function search_and_select($keyword)
{
    $keyword = Helper::clean_keyword($keyword);
    $data = Account::where
    ('number','like','%'.$keyword.'%')->
    orWhere('name','like','%'.$keyword.'%')->
    limit(30)->
    get(['user_id','number','name']);
    if(count($data) == 0)
        return Helper::no_result();
    return [$data,['number','name']];       
}

如果我尝试搜索任何有关此错误的信息

message: "Undefined index: foreign_name"
    1: {,…}
class: "App\Models\Account"
file: "C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasAttributes.php"
function: "getNameAttribute"
line: 465
type: "->"
2: {,…}
class: "Illuminate\Database\Eloquent\Model"
file: "C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasAttributes.php"
function: "mutateAttribute"
line: 479
type: "->"

但是如果我改变

return $this->attributes['foreign_name'];

return $this->attributes['id']; // or any integer field in the accounts table its working without problem 

与laravel 6它正在与我一起工作,但现在我盖特这个错误 任何帮助在这里..