1
在我的配置文件夾下,我有一個constants.php文件。我使用{{ json_encode(config('constants.pressMetadata')) }}
訪問常量文件中的pressMetadata對象。這將所有數據轉儲爲JSON對象。我想要做的是使用foreach循環打印出所有的數據。我試過在Laravel中訪問配置變量
@foreach (config('constants.pressMetadata') as $tile)
<p>{{$tile->id}}</p>
@endforeach
這不起作用。那麼我該怎麼做,所以我可以使用foreach循環遍歷config('constants.pressMetadata')對象?
這裏是常量pressMetadata
'pressMetadata'=>[
"AARP" => [
"id" => 1,
"company" => "AARP",
"title" => "Updating Your Résumé for the Digital Age",
"url" => "http://www.aarp.org/work/job-hunting/info-2016/give-resume-a-digital-reboot.html",
"date" => "Sep 9, 2016"
],
"Business Insider" => [
"id" => 2,
"company" => "Business Insider",
"title" => "8 things you should always include on your résumé",
"url" => "http://www.businessinsider.com/what-to-always-include-on-your-resume-2016-1",
"date" => "Jan 28, 2016"
],
"Morning Journal" => [
"id" => 3,
"company" => "Morning Journal",
"title" => "5 things you missed: Google updates search, Jobscan and more",
"url" => "http://www.morningjournal.com/article/MJ/20140124/NEWS/140129366",
"date" => "Jan 24, 2014"
],
],
顯示的'配置/ constants.php'配置請。 –
@AlexeyMezenin,我加了constants.php – Aaron