How to read JSON from api url with laravel 5.5 while maintaining the MVC format.
I have searched a lot about it but could not find any on point answer.
There are lots of ways to read/post JSON using ajax, but that will harm the architecture, so I want to use controller to parse JSON and then pass to view. or maybe is there a way to parse json into model first ?
There is also a plain solution of decoding JSON though simple php like this :
$rUrl = 'http://example.com/api/products'; $data = json_decode(file_get_contents($rUrl), true); return view('mydata')->withData($data); But Is there any better way to handle this in laravel ? and in which other ways I can maintain header and JSON results in laravel ?
is my question is not clear please comment to correct it. any help would be appreciated. Thanks in Advance !