The issue seems to be with the autoloading configuration in the composer.json file.
To fix this, you can try the following steps:
-
Make sure that the helper file is located at the correct path:
app/Helpers/GlobalPreferenceHelper.php. -
Run the following command to regenerate the autoloader files:
composer dump-autoload
- Verify that the
composer.jsonfile has been updated with the correct autoload configuration:
"autoload": {
"psr-4": {
"App\": "app/",
"Database\Factories\": "database/factories/",
"Database\Seeders\": "database/seeders/"
},
"files": [
"app/Helpers/GlobalPreferenceHelper.php"
]
},
- Finally, make sure to include the helper file in the file where you are using the
preferences()function. For example, if you are using it in a Blade template, you can include the helper file at the top of the template like this:
@php
require_once app_path('Helpers/GlobalPreferenceHelper.php');
@endphp
After following these steps, the preferences() function should be available for use in your application.