【发布时间】:2021-07-09 14:19:16
【问题描述】:
我正在从我的资源文件夹 resources/data/example.json 加载一个 json 文件
public function __construct()
{
// Load json file
$path = base_path('resources/data/rooms.json');
$content = file_get_contents($path);
$data = json_decode($content);
}
我的 json 文件是这样的,这是一个简单的例子:[ { "id":"bicycle", "category":"vehicle", "name":"Bicycle One", "images":[ "/img/bike_slider_1.jpg", "/img/bike_slider_2.jpg" ], },
所以现在我想知道如何将其中一些数据传递给视图,例如 bikes.blade.php
看起来像这样:
@extends('layouts.default') @section('content') <main>{{ content[1] }}</main>
任何帮助将不胜感激:)
【问题讨论】: