控制器更新方法在Laravel中不起作用

时间:2019-06-09 05:35:00

标签: laravel-5.2

我正在使用laravel 5.2。控制器方法的存储,显示和编辑工作正常,但更新方法无效。

edit.blade是:

@extends ('layouts.backend')
@section ('content')
<div class="pull-right">
<a class="btn btn-primary" href="{{ route('backend.index') }}"> Back</a>
</div>

<form method="PATCH" action="{{ route('backend.update', $reports->id) }}">

<div>
create report
</div>
<div>
<table>
<tr>
<td>
<div class="form-group required">
<label for="category_id" class="control-label">ID</label>
<input class="form-control" name="id" id="id" type="text" value="{{ $reports->id}}">
</div>
<div class="form-group required">
<label for="category_id" class="control-label">Category</label>
<select class="form-control" id="category" name="category"><option value="" selected="selected">Select</option><option value="1">Agriculture</option><option value="2">Food</option><option value="3">Beverage</option></select>
</div>
<div class="form-group required">
<label for="name" class="control-label">Name</label>
<input class="form-control" name="name" id="name" type="text" value="{{ $reports->name}}">
</div>
<div class="form-group required">
<label for="url" class="control-label">Url</label>
<input class="form-control" name="slug" id="slug" type="text" value="{{ $reports->slug}}">
</div>
<div class="form-group required">
<label>Brief Description</label></br>
<textarea id="brief_des" name="brief_des" rows="12" cols="70" style="width: 80%" >
{{ $reports->brief_des}}
</textarea>
</div>
<div class="form-group required">
<label>Full Description</label></br>
<textarea id="full_des" name="full_des" rows="12" cols="70" style="width: 80%">
{{ $reports->full_des}}
</textarea>
</div>

<input type="submit" value="Update"/>
</td>
<td>

</td>
</tr>
</table>
</div>
{{ Form::token() }}
</form>

@endsection

和控制器更新方法代码为:

public function update(Request $request, $id){

report::find($id)->update($request->all());
return redirect()->route('backend.index')
->with('success','Product Updated Successfully');
}

和route.php为:

Route::resource('backend', 'ReportController');

当我提交表单时,我的数据库中有任何更新,并且重定向也无法正常工作。

0 个答案:

没有答案