I receive JSON from Vue.JS client via REST Api, and I'd like to get data using Eloquent, but it doesn't work. It's not blade and not standard form-submit data, I receive JSON Api from client, single-page application.
This is the JSON, addressed to route '/order' from client, method POST:
{ "name": "John", "phone": "+7 794 910 5708", "email": "[email protected]" } The route is:
Route::post('/order','OrderController@order'); In a Controller I try to do that:
<?php namespace App\Http\Controllers; use Request; use App\Data; class OrderController extends Controller { public function order() { $input = Request::all(); $data = new Data; $data->name = $input['name']; $data->phone = $input['phone']; $data->save(); return response()->json(['result' => '200 OK'], 200); } } But nothing happens. What is the right syntax to receive data from REST Api?
dd(request()->all());? Put this in your order function as a first line.