laravel 5.2中的方法名称必须是字符串错误

时间:2017-03-04 18:45:50

标签: laravel laravel-5.2

尝试将数据插入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() !!}

请帮我找出错误

1 个答案:

答案 0 :(得分:0)

变化:

$this->$request([
    'title'=>'required',
    'description' => 'required'
]);

$this->validate($request, [
    'title'=>'required',
    'description' => 'required'
]);

希望这有帮助!