Reputation: 4141
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?
Upvotes: 3
Views: 7323
Reputation: 147
Run this command on terminal
php artisan config:clear
Upvotes: 0
Reputation: 7972
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
Upvotes: 16
Reputation: 116
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>
Upvotes: 0