我与onsubmit
合作。
在我的控制器中,我使用
laravael 5.3.9
但是当我尝试使用方法帖子从用户表单获取输入时:
Illuminate\Support\Facades\Input;
我收到此错误。
function add(){
$fullName = Input::post('fullName' , 'test');
我不想在我的系统中使用方法the only method that Input class has is "get" .
,post
,delete
....
答案 0 :(得分:0)
我猜,Input::post
方法不适用于L5.3。使用请求外观或$request
来获取输入变量。
在你的控制器中试试这个
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class area_owners extends Controller
{
function add(Request $request)
{
// I assume all these input variable have same name in you FORM.
$fullName = $request->input('fullName');
$smsCode = $request->input('smsCode');
$authorizationId = $request->input('authorizationId');
$areaNumber = $request->input('areaNumber');
$neigh_project_Id = $request->input('neigh_project_Id');
$area_owners = DB::table('area_owners')
->insert(['fullName'=>$fullName,
'smsCode'=>$smsCode,
'authorizationId'=>$authorizationId,
'areaNumer'=>$areaNumber,
'neigh_project_Id'=>$neigh_project_Id]);
return view('area_owners_add', ['area_owners' => $area_owners]);
}
}
如果有帮助,请告诉我。