Laravel 5.8-未找到"Arr"类

问题描述:

我已经升级到Laravel 5.8

I've upgraded to Laravel 5.8

根据5.8中的文档进行的更改之一是,不推荐使用所有array_ *和str_ *全局帮助程序(

One of the changes as per the docs in 5.8 is that All array_* and str_* global helpers have been deprecated (https://laravel.com/docs/5.8/upgrade#string-and-array-helpers)

在刀片视图中,我有以下内容:

In my blade view I have the following:

 {{ (Arr::has($queryString, 'industry') ? Arr::get($queryString, 'industry')  : '')  }}

这会引发错误:

Class 'Arr' not found...

如果我包含全名空间,那么它将起作用:

If I include the full name space then it works:

{{(Illuminate \ Support \ Arr :: has($ queryString,'industry')?Illuminate \ Support \ Arr :: get($ queryString,'industry'):'')}}

{{ (Illuminate\Support\Arr::has($queryString, 'industry') ? Illuminate\Support\Arr::get($queryString, 'industry') : '') }}

请告知.

我知道了.

需要更新应用程序配置文件,并将以下内容添加到别名数组:

Need to update the app config file and include the following to the aliases array:

'Arr' => Illuminate\Support\Arr::class,
'Str' => Illuminate\Support\Str::class,

然后清除配置缓存,以使新别名开始起作用: php artisan cache:clear

Then clear the config cache in order for the new aliases to start working: php artisan cache:clear

[编者注:先前的错字现已得到纠正]