Laravel 5.8-未找到"Arr"类 [英] Laravel 5.8 - Class 'Arr' not found

查看:84
本文介绍了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

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

这篇关于Laravel 5.8-未找到"Arr"类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆