看了博主的教程后,自己试着自己去完成一个标签的管理功能,于是把标签当成文章那样改了,但是标签并不需要Request表单验证。
个人标签的编辑代码
@extends('app')
@section('content')
<div class="col-md-10">
<div class="panel panel-default">
<div class="panel-heading">修改标签</div>
{!! Form::model($tag,['url'=>'admin/tags/update']) !!}
@if ($errors->has('error'))
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span></button>
<strong>Error!</strong>
{{ $errors->first('error', ':message') }}
<br />
请联系开发者!
</div>
@endif
<div class="panel-body">
{!! Form::open(['route' => 'admin.tags.store', 'method' => 'post','class'=>'form-horizontal']) !!}
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">标签名</label>
<div class="col-sm-3">
{!! Form::text('name', $tag->name, ['class' => 'form-control']) !!}
<font color="red">{{ $errors->first('name') }}</font>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
{!! Form::submit('修改', ['class' => 'btn btn-success']) !!}
</div>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
@endsection
TagsController里面update的代码:
public function update($id)
{
//根据id查询到需要更新的tag
$tag = Tag::find($id);
//使用Eloquent的update()方法来更新,
//request的except()是排除某个提交过来的数据,我们这里排除id
$tag->update($id->except('id'));
return redirect('/admin/tags');
}
结果就出现了这样的错误了:
ErrorException in D:\laravel5\app\Http\Controllers\Admin\TagsController.php line 74:
Missing argument 1 for App\Http\Controllers\Admin\TagsController::update()
74行就是public function update($id),
不知道少了哪个参数,求指导,怎样可以查看表单submit上传了什么数据?