I want to store some data in a JSON file. The data will be decoded using json_decode
function and passed to view.
File example:
{
"rooms": [
{
"name": "Aula Magna 1",
"camera_url": "camera url",
"audio_card": "audio card"
},
{
"name": "Aula Magna 2",
"camera_url": "camera url",
"audio_card": "audio card"
},
{
"name": "Aula Minor",
"camera_url": "camera url",
"audio_card": "audio card"
}]
}
I want to convert this file into an array so I can access it inside a view like so
@foreach( $rooms as $room)
....
@endforeach
Where inside Laravel folder structure should be data file like this stored?
You should put your file inside the storage
folder as it is a non-public directory.
You can also place it in resources
folder, but it is not the best place, as this folder is used for source files and is usually stored in source code repository (e.g. git).