Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.8 - Class 'Arr' not found

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.

like image 379
adam78 Avatar asked Apr 27 '19 14:04

adam78


1 Answers

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]

like image 136
adam78 Avatar answered Nov 17 '22 05:11

adam78