Unter meinem Config-Ordner habe ich eine constants.php-Datei. Ich habe das pressMetadata-Objekt in der Konstantendatei unter Verwendung von {{ json_encode(config('constants.pressMetadata')) }}
aufgerufen. Dadurch werden alle Daten als JSON-Objekt ausgegeben. Was ich versuche, ist, alle Daten mit einer foreach-Schleife auszudrucken. Ich habe versucht,Zugriff auf die Konfigurationsvariable in Laravel
@foreach (config('constants.pressMetadata') as $tile)
<p>{{$tile->id}}</p>
@endforeach
Das funktioniert nicht. Was soll ich tun, damit ich eine foreach-Schleife verwenden kann, um das Objekt bei config ('constants.pressMetadata') zu durchlaufen?
Hier Konstanten pressMetadata
ist'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"
],
],
Zeige der 'config/constants.php' Config bitte. –
@AlexeyMezenin, fügte ich constants.php hinzu – Aaron