I am trying to create a simple laravel crud, where I will be able to use a json file as database instead of MySQL. But it's returning "null" when I am trying to fetch data from the json file located in "resource/lang" folder .
The output is :
Please click to view the Image
My codes from controller :
public function getjson(){
$json = file_get_contents('../resources/lang/test.json');
$gravatar = json_decode($json);
dd($gravatar);
}
My json file (locating at resources/lang/test.json)
[
{
"id": 1,
"product_name": "Apple",
"per_item_price": "10",
"product_quanity": "4",
"total_price": "50",
},
{
"id": 2,
"product_name": "Apple",
"per_item_price": "10",
"product_quanity": "4",
"total_price": "50",
},
]
And The route from web.php is :
Route::get('/getjson', 'App\Http\Controllers\Master@getjson');


dd($json);ordd(json_last_error())?