Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message error

Posted 11 months ago by deladels

so i am trying to build a crude system. the index method works or more like all the get methods/verbs work. but anytime i try to submit a form or edit an entry i get the above error.

namespace App\Http\Controllers;

use App\AdminBus;

use Illuminate\Http\Request;

class AdminBusController extends Controller
{

    //function/action to get all buses in the db
    public function index(AdminBus $addbus)
    {
        $addbus = AdminBus::all();

        return view('admin.addbus.index', compact('addbus'));
    }


    //function/action to create a new bus
    public function create()
    {
        return view('admin.addbus.create');
    }

    public function store(Request $request)
    {
       $this->validate( request(), [

            'busRegNo'  => 'required',
            'busModel'  => 'required',
            'capacity'  => 'required'

        ]);

        AdminBus::create([

        'reg_number'  => request('busRegNo'),
        'model'       => request('busModel'),
        'capacity'    => request('capacity')

    ]);
            Session::flash('message', 'Successfully created nerd!');
            return Redirect::to('bus'); 
    }

    
    public function show($adminBus)
    {
        $adminBus = AdminBus::find($adminBus);

        return view('admin.addbus.show', compact('adminBus'));
    }

  
    public function edit($adminBus)
    {
        $adminBus = AdminBus::find($adminBus);

        return view('admin.addbus.edit', compact('adminBus'));
    }


    public function update(Request $request, AdminBus $adminBus)
    {
        $adminBus = AdminBus::find($adminBus);

       $this->validate( request(), [

            'busRegNo'  => 'required',
            'busModel'  => 'required',
            'capacity'  => 'required'

        ]);
       
        $adminBus->reg_number = $request->get('reg_number');
        $adminBus->model      = $request->get('model');
        $adminBus->capacity   = $request->get('capacity');
        $adminBus->save();

            Session::flash('message', 'Successfully created nerd!');
            return Redirect::to('bus');
    }

web.php file

Route::resource('bus', 'AdminBusController');

any help?

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.