问题
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