Asked by: Azima
I'm trying to access array from config file and use it in my dropdown list.
<select id="iconSelector" name="iconChoose" class="form-control" style="width: 100%">
@foreach(array(Config::get('azima')) as $icon)
<option value="{{$icon}}">{{$icon}}</option>
@endforeach
</select>
I have 'azima.php' file in config folder, which returns array and looks like this
<?php
return [
"ti-arrow-up",
"ti-arrow-right",
"ti-arrow-left",
"ti-angle-double-up"
];
The problem is it is working fine in other projects. What could be the problem?
Answers
Answered by: Andre Madarang at 2017-07-11 12:10PM
You don't have to cast it to an array:
<select id="iconSelector" name="iconChoose" class="form-control" style="width: 100%">
@foreach(Config::get('azima') as $icon)
<option value="{{$icon}}">{{$icon}}</option>
@endforeach
</select>
Answered by: linktoahref at 2017-07-11 12:44PM Accepted
You get null
maybe because the file hasn't been autoloaded. Clearing the cache and autoload dumping should do the trick
composer dump-autoload
php artisan config:clear
php artisan config:cache
No comments:
Post a Comment