Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined function Project\Http\Controllers\array_sort()

I tried to use the helper function array_sort(), but it returns an undefined function error. Please see my code below.

DashboardController

dd(array_sort($get_all_available_city));

I've created helpers.php by the way. Maybe it affects the functionality. But didn't override the array_sort(), and also I didn't put namespace on it.

UPDATE

I'm using laravel 7.

like image 670
Jie Avatar asked Dec 22 '22 17:12

Jie


1 Answers

You can't use string and array helpers from Laravel 6. laravel 6 removed helpers function from repo. You can use Illuminate\Support\Arr classes for helpers.

use Illuminate\Support\Arr;

Arr:::sort($get_all_available_city);

If you want to use helpers functions as array_sort then you need to install new composer package with following command :

composer require laravel/helpers

Then you can access :

array_sort($get_all_available_city);
like image 119
sta Avatar answered Jan 30 '23 13:01

sta