zaster
452
31
Laravel

MethodNotAllowedHttpException in RouteCollection.php

Posted 4 months ago by zaster

web.php

Route::prefix('employee')->group(function () {    

//More Routes

    //POItem Section
    Route::post('/poitem/create', 'Employee\[email protected]')->name('employee.poitem.create');
    Route::get('/poitem/pending', 'Employee\[email protected]')->name('employee.poitem.pendinglist');
    Route::delete('/poitem/{poitem}', 'Employee\[email protected]')->name('employee.poitem.destroy');
}

POItemController.php

    public function destroy($id)
    {        
        $po_item = POItem::find($id);
        $po_item->delete();
        return back()->with('success','Information has been  deleted');
    }  

poitems.create.blade.php

<div class="col-md-1">
  <form action="{{action('Employee\[email protected]', $po_item->id)}}" method="post">
      {{csrf_field()}}
      <input name="_method" type="hidden" value="DELETE">
      <button class="btn btn-danger" type="submit">Delete</button>
   </form>
</div>

Please sign in or create an account to participate in this conversation.