0

i currently have a table in my view that has a delete button to delete a specific row here is my code for the view (table only)

<table class="table table-striped table-hover" id="detailTable">
    <thead>
        <tr>
            <th>Record ID</th>
            <th>Student ID</th>
            <th>Student Name</th>
            <th>Parent Account ID</th>
            <th>Guardian Name</th>
            <th>Role</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach ($vpc as $key => $pc)
            <tr>
                    <td>{{ $pc->GuardianChildID }}</td>
                    <td>{{ $pc->StudentID }}</td>
                    <td>{{ $pc->full_name }}</td>
                    <td>{{ $pc->ParentAccountID }}</td>
                    <td>{{ $pc->pfull_name }}</td>
                    <td>{{ $pc->Roles }}</td>
                    <td><button class="btn">{{ HTML::linkRoute('delpc','Delete', array($pc->GuardianChildID)) }}</button></td>   
            </tr>
        @endforeach

    </tbody>

</table>

then in my route i have this code to handle the delete

Route::delete('viewa/{id}', array('as' => 'delpc', 'uses' => 'parentAcc@deleteAssignment'));

then in my controller here is the function that does the delete

public function deleteAssignment($id)
{
    $deletegc = guardianChild::where('GuardianChildID', '=' , $id)
              ->delete();

    return Redirect::to('viewa');
}

when executing this, im having a method not allowed exception .any ideas what im doing wrong?

BourneShady
  • 955
  • 2
  • 17
  • 36
  • Possible duplicate of [CRUD Laravel 4 how to link to destroy?](http://stackoverflow.com/questions/19643483/crud-laravel-4-how-to-link-to-destroy) – cre8 Oct 09 '15 at 08:19

1 Answers1

1

You need a form to use the delete action. Only a get action can be called by a normal link.

 {{ Form::open(array('route' => array('admin.pages.destroy', $page->id), 'method' => 'delete')) }}
        <button type="submit" class="btn btn-danger btn-mini">Delete</button>
    {{ Form::close() }}
cre8
  • 13,012
  • 8
  • 37
  • 61