尝试将数据插入laravel 5.2中的数据库时出现此错误。 查看此代码并找到我所做的错误
Controller.php这样
public function store(Request $request){
$this->$request([
'title'=>'required',
'description' => 'required'
]);
Item::create($request->all());
return redirect()->route('itemCRUD.index')
->with('success', 'Item created Successfully');
}
create.php(短代码)
{!! Form::open(array('route' => 'itemCRUD.store','method'=>'POST')) !!}
{!! Form::text('title', null, array('placeholder' => 'Title','class' => 'form-control')) !!}
{!! Form::textarea('description', null, array('placeholder' => 'Description','class' => 'form-control','style'=>'height:100px')) !!}
<button type="submit" class="btn btn-primary">Submit</button>
{!! Form::close() !!}
请帮我找出错误
答案 0 :(得分:0)
变化:
$this->$request([
'title'=>'required',
'description' => 'required'
]);
到
$this->validate($request, [
'title'=>'required',
'description' => 'required'
]);
希望这有帮助!