Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert json data in json file in Laravel 5.6

Tags:

json

php

laravel

I need convert my json data in file .json. I parsing data to array of json in this code

$movies = Movie::all();
return response()->json($movies);

I need create movies.json file. Where my file must be, which folder? And how to it?

like image 613
AleksandarMihailovic Avatar asked Dec 14 '22 14:12

AleksandarMihailovic


1 Answers

use

use Illuminate\Support\Facades\Storage;

and then

Storage::disk('public')->put('movies.json', response()->json($movies));

and this file will be save in public folder

like image 115
محمد يحيى علي عمار Avatar answered Dec 17 '22 23:12

محمد يحيى علي عمار