Hello everyone, I am trying to store my API resource response in .json file. I'm having two issue i don't how i can get data of next page in the loop and the second issue is i cant store data of $response in .json file until i write $response->toJson() . but this for some reason removes meta data
$posts = Post::paginate(10);
for ($i=1; $i <= $posts->lastPage(); $i++) {
// get posts from 2nd page and so on..
$response = PostApiResource::collection($posts);
return Storage::disk('local')->put("posts{$i}.json", $response);
}
@jlrdw I need to share the .json file with my client and the pagination has 3000+ pages, it would be great if I can automate this thing
Storage::disk('local')->put('test.txt', 'my-text'); // this works
$response = PostApiResource::collection($posts);
Storage::disk('local')->put("posts{$i}.json",$response); // this creates the file with no data in it but when I return $response it has data in it.