3 回答
TA贡献1816条经验 获得超4个赞
public function store(Request $request)
{
$this->validate($request,[
'fname' => 'required',
'lname' => 'required',
'email' => 'required',
'password' => 'required'
]);
$user = new Users();
$user->fname = $request->fname;
$user->lname = $request->lname;
$user->email = $request->email;
$user->password = Hash::make($request->password);
$user->save();
Toastr::success('User Successfully Saved','Success');
return redirect()->route('admin.user.index');
}
TA贡献1863条经验 获得超2个赞
试试这个
Route::post('/index','UserController@store')->name('index.store');
和刀片文件
route('index.store')
见 https://laravel.com/docs/5.8/routing#named-routes
TA贡献2016条经验 获得超9个赞
您的web.php
Route::post('/index','UserController@store')->name('store');
添加缺少的表单method="POST"
@extends('layout.main')
@section('title','Index Page')
@section('content')
<div class="container">
<div class="row">
<form id="myform" action="{{route('store')}}" method="post">
@csrf
<div class="form-group">
<label for="fname">{{ trans('core.fname') }}</label>
<input type="text" class="form-control" id="fname" name="fname"/>
</div>
<div class="form-group">
<label for="fname">{{ trans('core.lname') }}</label>
<input type="text" class="form-control" id="lname" name="lname"/>
</div>
<div class="form-group">
<label for="fname">{{ trans('core.email') }}</label>
<input type="text" class="form-control" id="email" name="email"/>
</div>
<div class="form-group">
<label for="fname">{{ trans('core.password') }}</label>
<input type="password" class="form-control" id="password" name="password"/>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" id="submit" name="submit" value="{{trans('core.submit')}}"/>
</div>
</form>
</div>
</div>
@endsection
- 3 回答
- 0 关注
- 88 浏览
添加回答
举报