缺少[Route:role.destroy]的必需参数

问题描述

我发现了此错误 [路由:roles.destroy] [URI:角色/ {角色}]缺少必需的参数。 (查看:E:\ wamp64 \ www \ student_system \ resources \ views \ roles \ table.blade.PHP

<div class="table-responsive">
<table class="table" id="roles-table">
    <thead>
        <tr>
            <th>Name</th>
            <th colspan="3">Action</th>
        </tr>
    </thead>
    <tbody>
    @foreach($roles as $role)
        <tr>
            <td>{{ $role->name }}</td>
            <td>
                {!! Form::open(['route' => ['roles.destroy',$role->id],'method' => 'delete']) !!}
                <div class='btn-group'>
                    <a href="{{ route('roles.show',[$role->id]) }}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
                    <a href="{{ route('roles.edit',[$role->id]) }}" class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
                    {!! Form::button('<i class="glyphicon glyphicon-trash"></i>',['type' => 'submit','class' => 'btn btn-danger btn-xs','onclick' => "return confirm('Are you sure?')"]) !!}
                </div>
                {!! Form::close() !!}
            </td>
        </tr>
    @endforeach
    </tbody>
</table>

解决方法

我从未使用过Form类,但我认为您可以尝试仅传入$ role。