Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel 6 Call to undefined function Facuz\Theme\array_get()

Tags:

laravel

With laravel 6 theme and asset management package Facuz\Theme package

return an errot Call to undefined function Facuz\Theme\array_get()

return is_null($key) ? $this->themeConfig : array_get($this->themeConfig, $key);
like image 450
Ajay Avatar asked Dec 14 '22 10:12

Ajay


2 Answers

This appears to be a breaking change in Laravel 6.0

5.6 - Uses the following

array = ['products' => ['desk' => ['price' => 100]]];

$price = array_get($array, 'products.desk.price');

6.0 - Uses the following

$array = ['products' => ['desk' => ['price' => 100]]];

$price = Arr::get($array, 'products.desk.price');

https://laravel.com/docs/6.0/helpers#method-array-get

https://laravel.com/docs/5.6/helpers#method-array-get

It looks like this call is only used in 3 places in the codebase:

https://github.com/FaCuZ/laravel-theme/search?q=array_get&unscoped_q=array_get

Answer: Try update the calls in the package to match 6.0 ( Assuming there is no other breaking changes) this should work. If it works im sure a lot of people would be thankful for the pull request.

like image 80
Taylor Goodall AU Avatar answered Dec 17 '22 23:12

Taylor Goodall AU


Laravel 6.x and 7.x uses Arr::get() equivalent to array_get().To use it add the array facade on the top of your controller or php file use Illuminate\Support\Arr;

use Illuminate\Support\Arr;

$array = ['products' => ['desk' => ['price' => 100]]];
$price = Arr::get($array, 'products.desk.price');

For more info on laravel 6.x arrays and helpers

like image 35
KirtJ Avatar answered Dec 17 '22 23:12

KirtJ