Laravel 5.7 throws Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message error on calling update function

I've been using ajax post to update my database information with success using Laravel 5.2. The view, controller and model are in place but as I implement it using Laravel 5.7, I got this error

Symfony \ Component \ HttpKernel \ Exception \ > MethodNotAllowedHttpException No message.

Is there any changes or adjustment I have to make using Laravel 5.7? Please help. Thank you

View:

<form class="update-member-form" id="update-member-form" enctype="multipart/form-data">
   {{ csrf_field() }}

   <input type="text" name="id" class="form-control" id="primary_id" value="">

      <div class="form-group">
        <label for="recipient-name" class="col-form-label">Member ID:</label>
        <input type="text" name="member_id" class="form-control" id="member_id" value="" required>
      </div>
      <div class="form-group">
        <label for="recipient-name" class="col-form-label">First Name:</label>
        <input type="text" name="fname" class="form-control" id="editMember_name" value="" required>
      </div>
      <div class="form-group">
        <label for="recipient-name" class="col-form-label">Middle Name:</label>
        <input type="text" name="mname" class="form-control" id="editMember_mname" value="" required>
      </div>
      <div class="form-group">
        <label for="recipient-name" class="col-form-label">Last Name:</label>
        <input type="text" name="lname" class="form-control" id="editMember_lname" value="" required>
      </div>
</form>

<div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-dismiss="modal" onClick="window.location.reload()" >Close</button>
    <button type="button" class="btn btn-primary btn-update-member">Save updates</button>
  </div>

Javascript

$(".btn-update-member").click(function(e){

      e.preventDefault();

      $.post("{{ url('/updatemember') }}", $("#update-member-form").serialize(), function(data){

            if(data.notify == "Success"){

                swal({
                      title: "Record successfully updated",
                      text: "Message will close in 2 seconds",
                      type: "success",
                      timer: 2000
                    });

            } else{

              console.log(data.notify);

            }


          },"json"); 

      });

web.php

Route::post('/updatemember', 'MembersController@update');

Controller

public function update(Request $request, $id)
{
    //
    $updateMember = Member::where( 'id', $request['id'] )
                          ->update( $request->all() );

       if( $updateMember ){

         $notification = "Success";

       } else{

         $notification = "Failed";

       }

     return json_encode( array( 'notify'=>$notification ) );
}

Error:

Your route is wrong because you pass $id as parameter in your update function so please update your view file also

Route::post('/updatemember', 'MembersController@update');

change to

Route::post('/updatemember/{id}', 'MembersController@update');

Laravel 5.7 Error message “ Symfony \ Component \ HttpKernel , Laravel 5.7 Error message “ Symfony \ Component \ HttpKernel \ Exception HttpKernel \ Exception MethodNotAllowedHttpException No message compact​('about', 'categories')); } public function update(Request $request,  The most concise screencasts for the working developer, updated daily. There's no shortage of content at Laracasts. In fact, you could watch nonstop for days upon days, and still not see everything!

If you already put parameter then remove id from method:

public function update(Request $request)
{
    $updateMember = Member::where( 'id', $request['id'] )
                          ->update( $request->all() );    
       if( $updateMember ){    
         $notification = "Success";    
       } else{    
         $notification = "Failed";    
       }    
     return json_encode( array( 'notify'=>$notification ) );
}

OR

You have to change route to:

Route::post('/updatemember/{id}', 'MembersController@update');

and also in js:

$.post("{{ url('/updatemember/yourid') }}", $("#update-member-form").serialize(), function(data){
            if(data.notify == "Success"){
             ...
            } else{
              console.log(data.notify);
            }

EDIT : You have to pass value in id input which is empty:

<input type="text" name="id" class="form-control" id="primary_id" value="">

Laravel resource routing, Laravel returns MethodNotAllowedHttpException on routing does not exist. I created a route for buy an item in laravel 5.7 Route::post('/buy/item', specific, below is the exact error Postman shows Symfony \ Component \ HttpKernel \ Exception a request to POST /article will call the controller action: ArticleController#store. Laravel MethodNotAllowedHttpException No message - trying to Incert into mysql table I'm very new to Laravel, im currently using version 5.7. and as im trying to

The problem is the you are using POST but actually you have to perform PUT To fix this add

<input name="_method" type="hidden" value="PUT">

after form you just paste this

and don't forget

<form method="post">

Laravel API Tutorial: Building & Testing a RESTful API, Laravel 5.7 throws Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message error on calling update  Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException- laravel 5.7.28 Hot Network Questions Can a large corporation make a believable promise

Ok lets start Member.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Member extends Model
{
    // if you changed the primary key id you need to set it here
    protected $primaryKey = 'primary_id';
    protected $guarded = [];
    // Also to work it with route model binding you need this too
    public function getRouteKeyName()
    {
        return 'primary_id';
    }
}

Then web.php

// Get The Form name param has to be the same name as the controller variable
Route::get('/members/{member}/edit', 'MembersController@edit');
// Patch the form. 
// Not post because you are not creating. 
// Not put because you are not replacing. 
// Patch because you are updating 
Route::patch('/members/{member}/edit', 'MembersController@update')->name('member.update');

Then MembersController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Member;

class MembersController extends Controller
{
    // Bind the route to the model. It throws 404 if the member does not exit;
    public function edit(Request $request, Member $member)
    {
        return view('members.edit', compact('member'));
    }

    public function update(Request $request, Member $member)
    {
        die('i am here update');
    }
}

And of course the form

<form class="update-member-form" id="update-member-form" enctype="multipart/form-data">
   @csrf
   @method('PATCH') 
    <div class="form-group">
      <label for="recipient-name" class="col-form-label">Member ID:</label>
      <input type="text" name="member_id" class="form-control" id="member_id" value="{{$member->member_id}}" required>
    </div>
    <div class="form-group">
      <label for="recipient-name" class="col-form-label">First Name:</label>
      <input type="text" name="fname" class="form-control" id="editMember_name" value="{{$member->fname}}" required>
    </div>
    <div class="form-group">
      <label for="recipient-name" class="col-form-label">Middle Name:</label>
      <input type="text" name="mname" class="form-control" id="editMember_mname" value="{{$member->mname}}" required>
    </div>
    <div class="form-group">
      <label for="recipient-name" class="col-form-label">Last Name:</label>
      <input type="text" name="lname" class="form-control" id="editMember_lname" value="{{$member->lname}}" required>
    </div>
</form>

<div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-dismiss="modal" onClick="window.location.reload()" >Close</button>
    <button type="button" class="btn btn-primary btn-update-member">Save updates</button>
  </div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
  $(".btn-update-member").click(function(e){

  e.preventDefault();

  $.post("{{ route('member.update', $member->primary_id) }}", $("#update-member-form").serialize(), function(data){

        if(data.notify == "Success"){

            swal({
                  title: "Record successfully updated",
                  text: "Message will close in 2 seconds",
                  type: "success",
                  timer: 2000
                });

        } else{

          console.log(data.notify);

        }


      },"json"); 

  });
</script>

Of course you can avoid route model binding and get the id from input field or just as an int id from the route and then query through the db check if the member exits and bla bla bla.

Upgrade Guide - Laravel, Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException I followed document I got this error. Can you please tell me why this error? guy  the package is working just fine but after a few days the routes that uses the Middleware of the package become inaccessible and the following errors triggers from no where For example all controllers that uses this __construct() like Us

This line of code works for me. By just adding the ->except('_token')

 Member::where( 'id', $request['id'])->update($request->except('_token'));

Laravel - Update always throws , Laravel 7 upgraded its underlying Symfony components to the 5.x series, methods of your application's App\Exceptions\Handler class should Please update your calls to this method accordingly. In addition, please install the ^2.0 release of the symfony/psr-http-message-bridge Composer package. The most concise screencasts for the working developer, updated daily. There's no shortage of content at Laracasts. In fact, you could watch nonstop for days upon days, and still not see everything!

[Bug] Laravel 5.5 with Passport returning 419 response · Issue #539 , Laravel - Update always throws "MethodNotAllowedHttpException No message". From my research, this error is related to a routing error. As this error is thrown regardless of the code I utilize in my update function, that makes sense. However I Symfony\Component\HttpKernel\Exception\NotFoundHtt. The most concise screencasts for the working developer, updated daily. There's no shortage of content at Laracasts. In fact, you could watch nonstop for days upon days, and still not see everything!

Easy roles and permissions in Laravel 5, I am getting a 419 error response trying to use Passport with Laravel. my App\​User; Call the Passport::routes method within the boot method of /vendor/​laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", 5.5 returning back to page throws 419 response says view not found "message": "", . Basic Routing. The most basic Laravel routes accept a URI and a Closure, providing a very simple and expressive method of defining routes: Route::get('foo', function { return 'Hello World'; }); The Default Route Files. All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically

Symfony Component HttpKernel Exception , Laravel comes with Authentication and Authorization out of the box, I have public function run() { // Ask for db migration refresh, default is no if php artisan migrate:refresh $this->command->call('migrate:refresh'); else { flash()->error('​Unable to create user. Symfony Component HttpKernel Exception  The update method expects an array of column and value pairs representing the columns that should be updated. {note} When issuing a mass update via Eloquent, the saving, saved, updating, and updated model events will not be fired for the updated models. This is because the models are never actually retrieved when issuing a mass update.

Comments
  • It returns 404 Sorry, the page you are looking for could not be found. error
  • Laravel 5.7 already put that paramater $id in default. I did not put that as parameter.
  • so please remove $id form update function and please check
  • dump you request object and check all params you are getting or not
  • set id as value insted of value="" in id input
  • Still nothing :(
  • check you are getting id in request or not
  • change $request['id'] to $request->id