将post参数从主干传递到laravel
我正在后端工作,我想知道如何从将post参数从主干传递到laravel,post,backbone.js,parameters,request,laravel,Post,Backbone.js,Parameters,Request,Laravel,我正在后端工作,我想知道如何从backbone.js获取参数名文件的post请求。 我想将名为name的参数存储在我的数据库中。 以下是我的文件: 路线: Route::post('insert_document_details',array('as'=>'insert_document_details', 'uses'=>'AuthorsController@post_document_details')); 控制器: public function post_docum
backbone.js
获取参数名文件的post请求。
我想将名为name
的参数存储在我的数据库中。
以下是我的文件:
路线:
Route::post('insert_document_details',array('as'=>'insert_document_details',
'uses'=>'AuthorsController@post_document_details'));
控制器:
public function post_document_details()
{
// Store the original input of the request and then replace the input with your request instances input.
$response = Request::input();
$document_details=Response::json(Author::insert_document_details_Call($response));
return $document_details;
}
型号:
public static function insert_document_details_Call($response)
{
return DB::select('call insert_document_details');
}
这里,
insert\u document\u details
是一个存储过程,用于在数据库中插入数据,该数据库需要参数name
使用Laravel中的Input
类:使用Laravel中的Input
类可以如下调用存储过程:DB::statement(DB::raw('CALL insert_document_details('.$response['name']);)
。为什么不使用Input::get(…)
或Input::all()
而不是Request::Input()
?可以按如下方式调用存储过程:DB::statement(DB::raw('CALL insert_document_details('.$response['name'])););
。为什么不使用Input::get(…)
或Input::all()
而不是Request::Input()
?