新手到Laravel,尝试制作一个使用POST发送单个参数的表单.我想使用表单中输入的第一个名称在DB表中查询姓氏.
我想我把错误缩小到我的路线:
Route::post('get_last', function()
{
$query= 'SELECT last FROM "names" WHERE first =?';
$bindings= array(Input::post('first_name'));
$last_name = Name::selectOne($query, $bindings);
Redirect::route('last_name', array('last_name' => $last_name));
});
Run Code Online (Sandbox Code Playgroud)
重定向是一个应该显示结果的页面,我手动测试了一个,它似乎工作.我相信错误也可能是刀片文件中的内容:
@extends('layout')
@section('content')
{{ Form::open(array('url' => 'get_last', 'method' => 'POST')) }}
{{ Form::text('first_name', 'First Name') }}
{{ Form::submit('Search') }}
{{ Form::close() }}
@stop
Run Code Online (Sandbox Code Playgroud)
作为参考,这是我运行时获得的异常:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Call to undefined method Illuminate\Http\Request::post()
Run Code Online (Sandbox Code Playgroud)