Question and answer is powered by AnsPress.io
How to convert data to JSON when data select from database in laravel
Use in model:
$select_data=DB::table(‘table name’)->get();
json_encode($select_data);
If you are going to print it in your model, so you can try this code:
$select_data=DB::table(‘table name’)->get();
$json_data=json_encode($select_data);
print_r($json_data);