Laravel 5.8 - Class 'Arr' not found

耗尽温柔 提交于 2020-12-10 02:03:09

问题


I've upgraded to Laravel 5.8

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')  : '')  }}

This is throwing error:

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') : '') }}

Please advise.


回答1:


I figured it out.

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,

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

[editor's note: an earlier typo has now been corrected]



来源:https://stackoverflow.com/questions/55881379/laravel-5-8-class-arr-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!